diff options
| author | Jacob Pratt <jacob@jhpratt.dev> | 2022-05-21 13:53:26 -0400 |
|---|---|---|
| committer | Jacob Pratt <jacob@jhpratt.dev> | 2022-05-21 14:22:06 -0400 |
| commit | 8cece636b22620717d6e242ec20fa8d5cf979072 (patch) | |
| tree | bfcf6e492b64bb653abed0a4c9530df51658624b /compiler/rustc_parse/src | |
| parent | 69702468865d582f512df31a52ac2608afe5df0d (diff) | |
| download | rust-8cece636b22620717d6e242ec20fa8d5cf979072.tar.gz rust-8cece636b22620717d6e242ec20fa8d5cf979072.zip | |
Remove feature: `crate` visibility modifier
Diffstat (limited to 'compiler/rustc_parse/src')
| -rw-r--r-- | compiler/rustc_parse/src/parser/item.rs | 3 | ||||
| -rw-r--r-- | compiler/rustc_parse/src/parser/mod.rs | 24 |
2 files changed, 5 insertions, 22 deletions
diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 0f940cffcc4..e99347206fe 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -302,8 +302,7 @@ impl<'a> Parser<'a> { /// When parsing a statement, would the start of a path be an item? pub(super) fn is_path_start_item(&mut self) -> bool { - self.is_crate_vis() // no: `crate::b`, yes: `crate $item` - || self.is_kw_followed_by_ident(kw::Union) // no: `union::b`, yes: `union U { .. }` + self.is_kw_followed_by_ident(kw::Union) // no: `union::b`, yes: `union U { .. }` || self.check_auto_or_unsafe_trait_item() // no: `auto::b`, yes: `auto trait X { .. }` || self.is_async_fn() // no(2015): `async::b`, yes: `async fn` || matches!(self.is_macro_rules_item(), IsMacroRulesItem::Yes{..}) // no: `macro_rules::b`, yes: `macro_rules! mac` diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index 5bd07c31c0e..ebe3d00cf73 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -25,7 +25,7 @@ use rustc_ast::tokenstream::{self, DelimSpan, Spacing}; use rustc_ast::tokenstream::{TokenStream, TokenTree}; use rustc_ast::AttrId; use rustc_ast::DUMMY_NODE_ID; -use rustc_ast::{self as ast, AnonConst, AttrStyle, AttrVec, Const, CrateSugar, Extern}; +use rustc_ast::{self as ast, AnonConst, AttrStyle, AttrVec, Const, Extern}; use rustc_ast::{Async, Expr, ExprKind, MacArgs, MacArgsEq, MacDelimiter, Mutability, StrLit}; use rustc_ast::{HasAttrs, HasTokens, Unsafe, Visibility, VisibilityKind}; use rustc_ast_pretty::pprust; @@ -1245,12 +1245,8 @@ impl<'a> Parser<'a> { res } - fn is_crate_vis(&self) -> bool { - self.token.is_keyword(kw::Crate) && self.look_ahead(1, |t| t != &token::ModSep) - } - - /// Parses `pub`, `pub(crate)` and `pub(in path)` plus shortcuts `crate` for `pub(crate)`, - /// `pub(self)` for `pub(in self)` and `pub(super)` for `pub(in super)`. + /// Parses `pub`, `pub(crate)` and `pub(in path)` plus shortcuts `pub(self)` for `pub(in self)` + /// and `pub(super)` for `pub(in super)`. /// If the following element can't be a tuple (i.e., it's a function definition), then /// it's not a tuple struct field), and the contents within the parentheses aren't valid, /// so emit a proper diagnostic. @@ -1258,17 +1254,6 @@ impl<'a> Parser<'a> { pub fn parse_visibility(&mut self, fbt: FollowedByType) -> PResult<'a, Visibility> { maybe_whole!(self, NtVis, |x| x.into_inner()); - self.expected_tokens.push(TokenType::Keyword(kw::Crate)); - if self.is_crate_vis() { - self.bump(); // `crate` - self.sess.gated_spans.gate(sym::crate_visibility_modifier, self.prev_token.span); - return Ok(Visibility { - span: self.prev_token.span, - kind: VisibilityKind::Crate(CrateSugar::JustCrate), - tokens: None, - }); - } - if !self.eat_keyword(kw::Pub) { // We need a span for our `Spanned<VisibilityKind>`, but there's inherently no // keyword to grab a span from for inherited visibility; an empty span at the @@ -1293,10 +1278,9 @@ impl<'a> Parser<'a> { self.bump(); // `(` self.bump(); // `crate` self.expect(&token::CloseDelim(Delimiter::Parenthesis))?; // `)` - let vis = VisibilityKind::Crate(CrateSugar::PubCrate); return Ok(Visibility { span: lo.to(self.prev_token.span), - kind: vis, + kind: VisibilityKind::Crate, tokens: None, }); } else if self.is_keyword_ahead(1, &[kw::In]) { |
