Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

meta matches pseudo-identifiers #59881

Open
gnzlbg opened this issue Apr 11, 2019 · 1 comment
Open

meta matches pseudo-identifiers #59881

gnzlbg opened this issue Apr 11, 2019 · 1 comment
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@gnzlbg
Copy link
Contributor

gnzlbg commented Apr 11, 2019

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 } }
  |     ^

This also fails (playground):

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.

cc @petrochenkov @Centril @nrc @alexcrichton

@jonas-schievink jonas-schievink added the A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) label Apr 11, 2019
@jonas-schievink jonas-schievink added C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team, which will review and decide on the PR/issue. labels Jun 11, 2019
@lolbinarycat lolbinarycat added the S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue label Sep 8, 2024
@lolbinarycat
Copy link
Contributor

triage: still broken on latest stable and nightly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants