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

macro expanding to nothing in match arm causes uninformative parse error #30128

Closed
durka opened this issue Dec 1, 2015 · 4 comments · Fixed by #55292
Closed

macro expanding to nothing in match arm causes uninformative parse error #30128

durka opened this issue Dec 1, 2015 · 4 comments · Fixed by #55292
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug.

Comments

@durka
Copy link
Contributor

durka commented Dec 1, 2015

Failing code:

macro_rules! empty { () => () }

fn main() {
    match 42 {
        _ => empty!()
    };
}

The error is "unexpected token: <eof>" with a span of 1:1: 1:1.

Workaround:

macro_rules! empty { () => () }

fn main() {
    match 42 {
        _ => { empty!(); }
    };
}

Expected: the failing code either compiles or at least gives an error pointing at the problem.

Found by mohawk on IRC.

@makoConstruct
Copy link

A further reduced case, probably the same problem:

macro_rules! mac { () => () }

fn main(){ let a = mac!(); }

Likely connected to #10951 as well.

@Mark-Simulacrum Mark-Simulacrum added the A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) label May 10, 2017
@Mark-Simulacrum Mark-Simulacrum added A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. labels Jul 24, 2017
@estebank
Copy link
Contributor

Possibly related to #26288.

@estebank
Copy link
Contributor

CC #27569

@estebank
Copy link
Contributor

CC #33953

kennytm added a commit to kennytm/rust that referenced this issue Oct 26, 2018
Macro diagnostics tweaks

Fix rust-lang#30128, fix rust-lang#10951 by adding an appropriate span to the diagnostic.
Fix rust-lang#26288 by suggesting adding semicolon to macro call.
kennytm added a commit to kennytm/rust that referenced this issue Oct 26, 2018
Macro diagnostics tweaks

Fix rust-lang#30128, fix rust-lang#10951 by adding an appropriate span to the diagnostic.
Fix rust-lang#26288 by suggesting adding semicolon to macro call.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants