Skip to content

Need more helpful diagnositics for label values. #102391

@crlf0710

Description

@crlf0710

Given the following code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=781876a356578cbf3da13b05f8e40ba5

macro_rules! foo {
    ($v:expr, $l:lifetime) => {
        {
            dbg!($v);
            break $l
        }
    }
}
fn main () {
    'x: loop {
        // foo!(42, 'x); // correct usage
        foo!('x);
    }
}

The current output is:

error: expected `while`, `for`, `loop` or `{` after a label
  --> src/main.rs:12:14
   |
12 |         foo!('x);
   |              ^^ expected `while`, `for`, `loop` or `{` after a label

The error and diagnostics is ... kind of not pointing to the correct fix.

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, ..)A-parserArea: The lexing & parsing of Rust source code to an ASTD-lack-of-suggestionDiagnostics: Adding a (structured) suggestion would increase the quality of the diagnostic.D-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions