Skip to content

Confusing arrow positioning on macro error message #47778

Closed
@varkor

Description

@varkor
// 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-enhancementCategory: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions