@@ -1245,8 +1245,8 @@ impl<'a> Parser<'a> {
12451245 res
12461246 }
12471247
1248- /// Parses `pub`, `pub(crate)` and `pub(in path)` plus shortcuts `pub(self )` for `pub(in self)`
1249- /// and `pub(super)` for `pub(in super)`.
1248+ /// Parses `pub` and `pub(in path)` plus shortcuts `pub(crate )` for `pub(in crate)`, `pub( self)`
1249+ /// for `pub(in self)` and `pub(super)` for `pub(in super)`.
12501250 /// If the following element can't be a tuple (i.e., it's a function definition), then
12511251 /// it's not a tuple struct field), and the contents within the parentheses aren't valid,
12521252 /// so emit a proper diagnostic.
@@ -1271,19 +1271,7 @@ impl<'a> Parser<'a> {
12711271 // `()` or a tuple might be allowed. For example, `struct Struct(pub (), pub (usize));`.
12721272 // Because of this, we only `bump` the `(` if we're assured it is appropriate to do so
12731273 // by the following tokens.
1274- if self . is_keyword_ahead ( 1 , & [ kw:: Crate ] ) && self . look_ahead ( 2 , |t| t != & token:: ModSep )
1275- // account for `pub(crate::foo)`
1276- {
1277- // Parse `pub(crate)`.
1278- self . bump ( ) ; // `(`
1279- self . bump ( ) ; // `crate`
1280- self . expect ( & token:: CloseDelim ( Delimiter :: Parenthesis ) ) ?; // `)`
1281- return Ok ( Visibility {
1282- span : lo. to ( self . prev_token . span ) ,
1283- kind : VisibilityKind :: Crate ,
1284- tokens : None ,
1285- } ) ;
1286- } else if self . is_keyword_ahead ( 1 , & [ kw:: In ] ) {
1274+ if self . is_keyword_ahead ( 1 , & [ kw:: In ] ) {
12871275 // Parse `pub(in path)`.
12881276 self . bump ( ) ; // `(`
12891277 self . bump ( ) ; // `in`
@@ -1296,11 +1284,11 @@ impl<'a> Parser<'a> {
12961284 tokens : None ,
12971285 } ) ;
12981286 } else if self . look_ahead ( 2 , |t| t == & token:: CloseDelim ( Delimiter :: Parenthesis ) )
1299- && self . is_keyword_ahead ( 1 , & [ kw:: Super , kw:: SelfLower ] )
1287+ && self . is_keyword_ahead ( 1 , & [ kw:: Crate , kw :: Super , kw:: SelfLower ] )
13001288 {
1301- // Parse `pub(self)` or `pub(super)`.
1289+ // Parse `pub(crate)`, `pub( self)`, or `pub(super)`.
13021290 self . bump ( ) ; // `(`
1303- let path = self . parse_path ( PathStyle :: Mod ) ?; // `super`/`self`
1291+ let path = self . parse_path ( PathStyle :: Mod ) ?; // `crate`/` super`/`self`
13041292 self . expect ( & token:: CloseDelim ( Delimiter :: Parenthesis ) ) ?; // `)`
13051293 let vis = VisibilityKind :: Restricted { path : P ( path) , id : ast:: DUMMY_NODE_ID } ;
13061294 return Ok ( Visibility {
0 commit comments