Skip to content

Diagnostic error[E0408]: variable ... is not bound in all patterns should be more helpful with typos. #51976

@vi

Description

@vi

Example:

enum Lol {
    Foo,
    Bar,
}

fn foo(x: (Lol,Lol)) {
    use Lol::*;
    match x {
        (Foo,Bar)|(Ban,Foo) => {}
        _ => {}
    }
}

fn main() {
    use Lol::*;
    foo((Foo,Bar));
}
error[E0408]: variable `Ban` is not bound in all patterns
 --> src/main.rs:9:9
  |
9 |         (Foo,Bar)|(Ban,Foo) => {}
  |         ^^^^^^^^^  --- variable not in all patterns
  |         |
  |         pattern doesn't bind `Ban`

I want it to detect atypical upper-cased variable and trigger search for of enum variants with small edit distance. The notice about the type may be even shown before the actual error message itself to avoid missing it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`C-enhancementCategory: An issue proposing an enhancement or a PR with one.D-papercutDiagnostics: An error or lint that needs small tweaks.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

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions