Skip to content

Commit 3e7addc

Browse files
authored
Rollup merge of #69186 - petrochenkov:kwrules, r=Centril
[tiny] parser: `macro_rules` is a weak keyword r? @Centril
2 parents 5f0c593 + dcad07a commit 3e7addc

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

src/librustc_expand/mbe/macro_check.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ use crate::mbe::{KleeneToken, TokenTree};
109109
use rustc_data_structures::fx::FxHashMap;
110110
use rustc_session::lint::builtin::META_VARIABLE_MISUSE;
111111
use rustc_session::parse::ParseSess;
112-
use rustc_span::symbol::{kw, sym};
112+
use rustc_span::symbol::kw;
113113
use rustc_span::{symbol::Ident, MultiSpan, Span};
114114
use syntax::ast::NodeId;
115115
use syntax::token::{DelimToken, Token, TokenKind};
@@ -392,7 +392,7 @@ fn check_nested_occurrences(
392392
NestedMacroState::Empty,
393393
&TokenTree::Token(Token { kind: TokenKind::Ident(name, false), .. }),
394394
) => {
395-
if name == sym::macro_rules {
395+
if name == kw::MacroRules {
396396
state = NestedMacroState::MacroRules;
397397
} else if name == kw::Macro {
398398
state = NestedMacroState::Macro;

src/librustc_expand/parse/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ fn string_to_tts_macro() {
6565

6666
match tts {
6767
[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)]
68-
if name_macro_rules == &sym::macro_rules && name_zip.as_str() == "zip" =>
68+
if name_macro_rules == &kw::MacroRules && name_zip.as_str() == "zip" =>
6969
{
7070
let tts = &macro_tts.trees().collect::<Vec<_>>();
7171
match &tts[..] {

src/librustc_parse/parser/item.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1343,14 +1343,14 @@ impl<'a> Parser<'a> {
13431343

13441344
/// Is this unambiguously the start of a `macro_rules! foo` item defnition?
13451345
fn is_macro_rules_item(&mut self) -> bool {
1346-
self.check_keyword(sym::macro_rules)
1346+
self.check_keyword(kw::MacroRules)
13471347
&& self.look_ahead(1, |t| *t == token::Not)
13481348
&& self.look_ahead(2, |t| t.is_ident())
13491349
}
13501350

13511351
/// Parses a legacy `macro_rules! foo { ... }` declarative macro.
13521352
fn parse_item_macro_rules(&mut self, vis: &Visibility) -> PResult<'a, ItemInfo> {
1353-
self.expect_keyword(sym::macro_rules)?; // `macro_rules`
1353+
self.expect_keyword(kw::MacroRules)?; // `macro_rules`
13541354
self.expect(&token::Not)?; // `!`
13551355

13561356
let ident = self.parse_ident()?;

src/librustc_span/symbol.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ symbols! {
9797
Auto: "auto",
9898
Catch: "catch",
9999
Default: "default",
100+
MacroRules: "macro_rules",
100101
Raw: "raw",
101102
Union: "union",
102103
}
@@ -429,7 +430,6 @@ symbols! {
429430
macro_lifetime_matcher,
430431
macro_literal_matcher,
431432
macro_reexport,
432-
macro_rules,
433433
macros_in_extern,
434434
macro_use,
435435
macro_vis_matcher,
@@ -1071,6 +1071,9 @@ pub mod sym {
10711071

10721072
symbols!();
10731073

1074+
// Used from a macro in `librustc_feature/accepted.rs`
1075+
pub use super::kw::MacroRules as macro_rules;
1076+
10741077
// Get the symbol for an integer. The first few non-negative integers each
10751078
// have a static symbol and therefore are fast.
10761079
pub fn integer<N: TryInto<usize> + Copy + ToString>(n: N) -> Symbol {

0 commit comments

Comments
 (0)