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

Confusing error message from missing semicolon after macro invocation #26288

Closed
wthrowe opened this issue Jun 14, 2015 · 1 comment · Fixed by #55292
Closed

Confusing error message from missing semicolon after macro invocation #26288

wthrowe opened this issue Jun 14, 2015 · 1 comment · Fixed by #55292
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@wthrowe
Copy link
Contributor

wthrowe commented Jun 14, 2015

This code

macro_rules! foo {
    () => {
        assert_eq!("A", "A");
        assert_eq!("B", "B");
    }
}

fn main() {
    foo!()
}

gives the error:

foo.rs:4:9: 4:18 error: macro expansion ignores token `assert_eq` and any following
foo.rs:4         assert_eq!("B", "B");
                 ^~~~~~~~~
foo.rs:9:5: 9:11 note: caused by the macro expansion here; the usage of `foo` is likely invalid in this context
foo.rs:9     foo!()
             ^~~~~~
error: aborting due to previous error

The problem is actually a missing semicolon after foo!(), but the message wasn't really helpful in figuring that out. (I initially left out the semicolon out of habit from C, where including it would result in an extra empty statement after expansion.)

@steveklabnik steveklabnik added the A-diagnostics Area: Messages for errors, warnings, and lints label Jun 15, 2015
@steveklabnik
Copy link
Member

Triage: no change

@steveklabnik steveklabnik added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 9, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Jul 22, 2017
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 C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants