mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
parser: macro_rules
is a weak keyword
This commit is contained in:
parent
19288ddfd6
commit
dcad07af8a
@ -109,7 +109,7 @@ use crate::mbe::{KleeneToken, TokenTree};
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_session::lint::builtin::META_VARIABLE_MISUSE;
|
||||
use rustc_session::parse::ParseSess;
|
||||
use rustc_span::symbol::{kw, sym};
|
||||
use rustc_span::symbol::kw;
|
||||
use rustc_span::{symbol::Ident, MultiSpan, Span};
|
||||
use syntax::ast::NodeId;
|
||||
use syntax::token::{DelimToken, Token, TokenKind};
|
||||
@ -392,7 +392,7 @@ fn check_nested_occurrences(
|
||||
NestedMacroState::Empty,
|
||||
&TokenTree::Token(Token { kind: TokenKind::Ident(name, false), .. }),
|
||||
) => {
|
||||
if name == sym::macro_rules {
|
||||
if name == kw::MacroRules {
|
||||
state = NestedMacroState::MacroRules;
|
||||
} else if name == kw::Macro {
|
||||
state = NestedMacroState::Macro;
|
||||
|
@ -65,7 +65,7 @@ fn string_to_tts_macro() {
|
||||
|
||||
match tts {
|
||||
[TokenTree::Token(Token { kind: token::Ident(name_macro_rules, false), .. }), TokenTree::Token(Token { kind: token::Not, .. }), TokenTree::Token(Token { kind: token::Ident(name_zip, false), .. }), TokenTree::Delimited(_, macro_delim, macro_tts)]
|
||||
if name_macro_rules == &sym::macro_rules && name_zip.as_str() == "zip" =>
|
||||
if name_macro_rules == &kw::MacroRules && name_zip.as_str() == "zip" =>
|
||||
{
|
||||
let tts = ¯o_tts.trees().collect::<Vec<_>>();
|
||||
match &tts[..] {
|
||||
|
@ -1343,14 +1343,14 @@ impl<'a> Parser<'a> {
|
||||
|
||||
/// Is this unambiguously the start of a `macro_rules! foo` item defnition?
|
||||
fn is_macro_rules_item(&mut self) -> bool {
|
||||
self.check_keyword(sym::macro_rules)
|
||||
self.check_keyword(kw::MacroRules)
|
||||
&& self.look_ahead(1, |t| *t == token::Not)
|
||||
&& self.look_ahead(2, |t| t.is_ident())
|
||||
}
|
||||
|
||||
/// Parses a legacy `macro_rules! foo { ... }` declarative macro.
|
||||
fn parse_item_macro_rules(&mut self, vis: &Visibility) -> PResult<'a, ItemInfo> {
|
||||
self.expect_keyword(sym::macro_rules)?; // `macro_rules`
|
||||
self.expect_keyword(kw::MacroRules)?; // `macro_rules`
|
||||
self.expect(&token::Not)?; // `!`
|
||||
|
||||
let ident = self.parse_ident()?;
|
||||
|
@ -97,6 +97,7 @@ symbols! {
|
||||
Auto: "auto",
|
||||
Catch: "catch",
|
||||
Default: "default",
|
||||
MacroRules: "macro_rules",
|
||||
Raw: "raw",
|
||||
Union: "union",
|
||||
}
|
||||
@ -429,7 +430,6 @@ symbols! {
|
||||
macro_lifetime_matcher,
|
||||
macro_literal_matcher,
|
||||
macro_reexport,
|
||||
macro_rules,
|
||||
macros_in_extern,
|
||||
macro_use,
|
||||
macro_vis_matcher,
|
||||
@ -1071,6 +1071,9 @@ pub mod sym {
|
||||
|
||||
symbols!();
|
||||
|
||||
// Used from a macro in `librustc_feature/accepted.rs`
|
||||
pub use super::kw::MacroRules as macro_rules;
|
||||
|
||||
// Get the symbol for an integer. The first few non-negative integers each
|
||||
// have a static symbol and therefore are fast.
|
||||
pub fn integer<N: TryInto<usize> + Copy + ToString>(n: N) -> Symbol {
|
||||
|
Loading…
Reference in New Issue
Block a user