@@ -25,7 +25,7 @@ use rustc_ast::tokenstream::{self, DelimSpan, Spacing};
25
25
use rustc_ast:: tokenstream:: { TokenStream , TokenTree } ;
26
26
use rustc_ast:: AttrId ;
27
27
use rustc_ast:: DUMMY_NODE_ID ;
28
- use rustc_ast:: { self as ast, AnonConst , AttrStyle , AttrVec , Const , CrateSugar , Extern } ;
28
+ use rustc_ast:: { self as ast, AnonConst , AttrStyle , AttrVec , Const , Extern } ;
29
29
use rustc_ast:: { Async , Expr , ExprKind , MacArgs , MacArgsEq , MacDelimiter , Mutability , StrLit } ;
30
30
use rustc_ast:: { HasAttrs , HasTokens , Unsafe , Visibility , VisibilityKind } ;
31
31
use rustc_ast_pretty:: pprust;
@@ -1245,30 +1245,15 @@ impl<'a> Parser<'a> {
1245
1245
res
1246
1246
}
1247
1247
1248
- fn is_crate_vis ( & self ) -> bool {
1249
- self . token . is_keyword ( kw:: Crate ) && self . look_ahead ( 1 , |t| t != & token:: ModSep )
1250
- }
1251
-
1252
- /// Parses `pub`, `pub(crate)` and `pub(in path)` plus shortcuts `crate` for `pub(crate)`,
1253
- /// `pub(self)` for `pub(in self)` and `pub(super)` for `pub(in super)`.
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)`.
1254
1250
/// If the following element can't be a tuple (i.e., it's a function definition), then
1255
1251
/// it's not a tuple struct field), and the contents within the parentheses aren't valid,
1256
1252
/// so emit a proper diagnostic.
1257
1253
// Public for rustfmt usage.
1258
1254
pub fn parse_visibility ( & mut self , fbt : FollowedByType ) -> PResult < ' a , Visibility > {
1259
1255
maybe_whole ! ( self , NtVis , |x| x. into_inner( ) ) ;
1260
1256
1261
- self . expected_tokens . push ( TokenType :: Keyword ( kw:: Crate ) ) ;
1262
- if self . is_crate_vis ( ) {
1263
- self . bump ( ) ; // `crate`
1264
- self . sess . gated_spans . gate ( sym:: crate_visibility_modifier, self . prev_token . span ) ;
1265
- return Ok ( Visibility {
1266
- span : self . prev_token . span ,
1267
- kind : VisibilityKind :: Crate ( CrateSugar :: JustCrate ) ,
1268
- tokens : None ,
1269
- } ) ;
1270
- }
1271
-
1272
1257
if !self . eat_keyword ( kw:: Pub ) {
1273
1258
// We need a span for our `Spanned<VisibilityKind>`, but there's inherently no
1274
1259
// keyword to grab a span from for inherited visibility; an empty span at the
@@ -1293,10 +1278,9 @@ impl<'a> Parser<'a> {
1293
1278
self . bump ( ) ; // `(`
1294
1279
self . bump ( ) ; // `crate`
1295
1280
self . expect ( & token:: CloseDelim ( Delimiter :: Parenthesis ) ) ?; // `)`
1296
- let vis = VisibilityKind :: Crate ( CrateSugar :: PubCrate ) ;
1297
1281
return Ok ( Visibility {
1298
1282
span : lo. to ( self . prev_token . span ) ,
1299
- kind : vis ,
1283
+ kind : VisibilityKind :: Crate ,
1300
1284
tokens : None ,
1301
1285
} ) ;
1302
1286
} else if self . is_keyword_ahead ( 1 , & [ kw:: In ] ) {
0 commit comments