Skip to content

"No item found" diagnostic should suggest items that differ by case #86170

Closed
@wesleywiser

Description

@wesleywiser

Given the following code: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=a494a5e7386a6c9e55f7f39695dece41

enum Foo {
    Bar(u32)
}

fn main() {
    matches!(todo!(), Foo::BAR(_));
}

The current output is:

error[E0599]: no variant or associated item named `BAR` found for enum `Foo` in the current scope
 --> src/main.rs:6:28
  |
1 | enum Foo {
  | -------- variant or associated item `BAR` not found here
...
6 |     matches!(todo!(), Foo::BAR(_));
  |                            ^^^ variant or associated item not found in `Foo`

Ideally the output should include a note suggesting the variant with the same name (but different case):

error[E0599]: no variant or associated item named `BAR` found for enum `Foo` in the current scope
 --> src/main.rs:6:28
  |
1 | enum Foo {
  | -------- variant or associated item `BAR` not found here
...
6 |     matches!(todo!(), Foo::BAR(_));
  |                            ^^^ variant or associated item not found in `Foo`
  | help: a similarly named variant exists: `Bar`

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.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