- 
                Notifications
    
You must be signed in to change notification settings  - Fork 13.9k
 
Open
Labels
A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-bugCategory: This is a bug.Category: This is a bug.S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language team
Description
This (playground) fails:
macro_rules! foo {
    ($($m:meta => $i:item)* _ => $j:item) => {};
}
foo! {
    _ => { fn f() -> i32 { 2 } }
}
fn main() { f(); }error: local ambiguity: multiple parsing options: built-in NTs meta ('m') or 1 other option.
 --> src/main.rs:6:5
  |
6 |     _ => { fn f() -> i32 { 2 } }
  |     ^
macro_rules! foo {
    ($m:meta) => {};
    (_ => { $i:item }) => {
        $i
    };
}
foo! {
    _ => { fn f() -> i32 { 2 } }
}
fn main() {  f(); }error: expected identifier, found reserved identifier `_`
 --> src/main.rs:9:5
  |
9 |     _ => { fn f() -> i32 { 2 } }
  |     ^ expected identifier, found reserved identifier
I believe both cases should work because meta should not match pseudo-identifiers.
Metadata
Metadata
Assignees
Labels
A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-bugCategory: This is a bug.Category: This is a bug.S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language team