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 arrow positioning on macro error message #47778

Closed
varkor opened this issue Jan 26, 2018 · 1 comment
Closed

Confusing arrow positioning on macro error message #47778

varkor opened this issue Jan 26, 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, ..) 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

@varkor
Copy link
Member

varkor commented Jan 26, 2018

// main.rs
#[macro_use]
mod other;

fn main() {
    let_var!(foo);
}
// other.rs
macro_rules! let_var {
    ($name:ident) => (
        let $name;
    )
}

Results in:

error[E0282]: type annotations needed
  --> main.rs:5:14
   |
 3 | |
   | |                 ^
   | |_________________|
   | |_________________cannot infer type for `_`
   |                   consider giving `foo` a type
 4 |   fn main() {
 5 |       let_var!(foo);
   |  _____---------^----
   | |_____|________|
   | |     |
   | |     in this macro invocation

The arrow in the first snippet is pointing to a blank snippet (it seems to the end of the line containing the module import). I'm not sure what the ideal case here is, but this seems a little confusing.

@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 Jan 26, 2018
@estebank
Copy link
Contributor

CC #32072.

@cuviper cuviper added 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. labels Jan 27, 2018
kennytm added a commit to kennytm/rust that referenced this issue Feb 2, 2018
…s Minimize weird spans involving macro context Sometimes the parser attempts to synthesize spans from within a macro context with the span for the captured argument, leading to non-sensical spans with very bad output. Given that an incorrect span is worse than a partially incomplete span, when detecting this situation return only one of the spans without merging them. Fix rust-lang#32072, rust-lang#47778. CC rust-lang#23480.
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-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

No branches or pull requests

3 participants