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

Bad spans in macro error message #52866

Closed
RalfJung opened this issue Jul 30, 2018 · 1 comment
Closed

Bad spans in macro error message #52866

RalfJung opened this issue Jul 30, 2018 · 1 comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)

Comments

@RalfJung
Copy link
Member

This code

#![crate_type = "lib"]

macro_rules! expensive_static {
    ($name: ident : $T: ty = $e : expr) =>
        (pub static $name : Vec<$T> = vec![$e])
}

expensive_static!(Y : &'static str = "hello");

produces the following error:

error: expected one of `.`, `;`, `?`, or an operator, found `<eof>`
 --> src/lib.rs:5:43
  |
5 |         (pub static $name : Vec<$T> = vec![$e])
  |                                           ^^^^ expected one of `.`, `;`, `?`, or an operator here

So I thought something was wrong with the arguments to the vec! macro. But really the problem is that I forgot the ; after that macro. Thankfully someone on IRC knew, I would never have figured that out...

Can the error message be improved?

@estebank estebank added A-diagnostics Area: Messages for errors, warnings, and lints A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) labels Jul 30, 2018
@estebank
Copy link
Contributor

CC #27569

estebank added a commit to estebank/rust that referenced this issue Nov 23, 2018
bors added a commit that referenced this issue Nov 27, 2018
Point at end of macro arm when encountering EOF

Fix #52866.
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, ..)
Projects
None yet
Development

No branches or pull requests

2 participants