Skip to content

Give a better diagnostic for keywords with incorrect capitalization #77149

Open
@jyn514

Description

@jyn514

Notice the capitalization (playground):

fn f() {
    While let Some(x) = vec![].next() {
        //
    }
}
error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found keyword `let`
 --> src/lib.rs:2:11
  |
2 |     While let Some(x) = vec![].next() {
  |           ^^^ expected one of 8 possible tokens

Instead it would be nice to say

error: `While` is not a keyword
 --> src/lib.rs:2:11
  |
2 |     While let Some(x) = vec![].next() {
  |     ^^^^^ help: try `while` instead

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`D-confusingDiagnostics: Confusing error or lint that should be reworked.D-newcomer-roadblockDiagnostics: Confusing error or lint; hard to understand for new users.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