@@ -1245,8 +1245,8 @@ impl<'a> Parser<'a> {
1245
1245
res
1246
1246
}
1247
1247
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)`.
1250
1250
/// If the following element can't be a tuple (i.e., it's a function definition), then
1251
1251
/// it's not a tuple struct field), and the contents within the parentheses aren't valid,
1252
1252
/// so emit a proper diagnostic.
@@ -1271,19 +1271,7 @@ impl<'a> Parser<'a> {
1271
1271
// `()` or a tuple might be allowed. For example, `struct Struct(pub (), pub (usize));`.
1272
1272
// Because of this, we only `bump` the `(` if we're assured it is appropriate to do so
1273
1273
// 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 ] ) {
1287
1275
// Parse `pub(in path)`.
1288
1276
self . bump ( ) ; // `(`
1289
1277
self . bump ( ) ; // `in`
@@ -1296,11 +1284,11 @@ impl<'a> Parser<'a> {
1296
1284
tokens : None ,
1297
1285
} ) ;
1298
1286
} 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 ] )
1300
1288
{
1301
- // Parse `pub(self)` or `pub(super)`.
1289
+ // Parse `pub(crate)`, `pub( self)`, or `pub(super)`.
1302
1290
self . bump ( ) ; // `(`
1303
- let path = self . parse_path ( PathStyle :: Mod ) ?; // `super`/`self`
1291
+ let path = self . parse_path ( PathStyle :: Mod ) ?; // `crate`/` super`/`self`
1304
1292
self . expect ( & token:: CloseDelim ( Delimiter :: Parenthesis ) ) ?; // `)`
1305
1293
let vis = VisibilityKind :: Restricted { path : P ( path) , id : ast:: DUMMY_NODE_ID } ;
1306
1294
return Ok ( Visibility {
0 commit comments