Skip to content

E0004 lists incorrect secondary witnesses #36410

Closed
@jfirebaugh

Description

@jfirebaugh

#31020 added display of multiple witnesses to the error message for non-exhaustive match patterns. However, witnesses beyond the first one may have inappropriate types. For example:

enum Direction {
    North,
    East,
    South,
    West,
}

fn main() {
    match Some(Direction::North) {
        Some(Direction::North) => (),
        None => ()
    }
}

Output:

error[E0004]: non-exhaustive patterns: `Some(East)`, `South` and `West` not covered
 --> <anon>:9:11
  |
9 |     match Some(Direction::North) {
  |           ^^^^^^^^^^^^^^^^^^^^^^ patterns `Some(East)`, `South` and `West` not covered

error: aborting due to previous error

Here, "South and West not covered" should read "Some(South) and Some(West) not covered".

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions