@@ -25,7 +25,7 @@ use rustc_ast::tokenstream::{self, DelimSpan, Spacing};
2525use rustc_ast:: tokenstream:: { TokenStream , TokenTree } ;
2626use rustc_ast:: AttrId ;
2727use 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 } ;
2929use rustc_ast:: { Async , Expr , ExprKind , MacArgs , MacArgsEq , MacDelimiter , Mutability , StrLit } ;
3030use rustc_ast:: { HasAttrs , HasTokens , Unsafe , Visibility , VisibilityKind } ;
3131use rustc_ast_pretty:: pprust;
@@ -1245,30 +1245,15 @@ impl<'a> Parser<'a> {
12451245 res
12461246 }
12471247
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)`.
12541250 /// If the following element can't be a tuple (i.e., it's a function definition), then
12551251 /// it's not a tuple struct field), and the contents within the parentheses aren't valid,
12561252 /// so emit a proper diagnostic.
12571253 // Public for rustfmt usage.
12581254 pub fn parse_visibility ( & mut self , fbt : FollowedByType ) -> PResult < ' a , Visibility > {
12591255 maybe_whole ! ( self , NtVis , |x| x. into_inner( ) ) ;
12601256
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-
12721257 if !self . eat_keyword ( kw:: Pub ) {
12731258 // We need a span for our `Spanned<VisibilityKind>`, but there's inherently no
12741259 // keyword to grab a span from for inherited visibility; an empty span at the
@@ -1293,10 +1278,9 @@ impl<'a> Parser<'a> {
12931278 self . bump ( ) ; // `(`
12941279 self . bump ( ) ; // `crate`
12951280 self . expect ( & token:: CloseDelim ( Delimiter :: Parenthesis ) ) ?; // `)`
1296- let vis = VisibilityKind :: Crate ( CrateSugar :: PubCrate ) ;
12971281 return Ok ( Visibility {
12981282 span : lo. to ( self . prev_token . span ) ,
1299- kind : vis ,
1283+ kind : VisibilityKind :: Crate ,
13001284 tokens : None ,
13011285 } ) ;
13021286 } else if self . is_keyword_ahead ( 1 , & [ kw:: In ] ) {
0 commit comments