Skip to content

Better error messages for the nullary-enum-variant-versus-variable binding problem. #7807

Closed
@bblum

Description

@bblum

The problem is, of course, as follows:

import names::{Alice, Bob};
...
match name {
    Alice => ...,
    Bob   => ...,
    Carol => ..., // <- treated as a variable because of forgotten import
    _     => ..., //~ WARNING unreachable pattern
}

or:

match name {
    Alice => ...,
    Bob | Carol => ..., //~ ERROR variable Carol not bound in all patterns
}

We should be able to emit a hint that says something like Maybe you forgot to import Carol?.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-resolveArea: Name/path resolution done by `rustc_resolve` specifically

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions