1
Fork 0

Change internal naming of macros.

When a `macro_rules! foo { ... }` invocation is compiled the name used
is `foo`, not `macro_rules!`. This is different to all other macro
invocations, and confused me when I was inserted debugging println
statements for macro evaluation.

This commit changes it to `macro_rules` (or just `macro`), which is what
I expected. There are no externally visible changes.
This commit is contained in:
Nicholas Nethercote 2022-04-08 13:10:52 +10:00
parent 027a232755
commit 482b25b321

View file

@ -439,7 +439,8 @@ pub fn compile_declarative_macro(
let argument_gram = mbe::macro_parser::compute_locs(&sess.parse_sess, &argument_gram);
let parser = Parser::new(&sess.parse_sess, body, true, rustc_parse::MACRO_ARGUMENTS);
let mut tt_parser = TtParser::new(def.ident);
let mut tt_parser =
TtParser::new(Ident::with_dummy_span(if macro_rules { kw::MacroRules } else { kw::Macro }));
let argument_map = match tt_parser.parse_tt(&mut Cow::Borrowed(&parser), &argument_gram) {
Success(m) => m,
Failure(token, msg) => {