Skip to content

Message reporting missing patterns for inexhaustive match is misleading #72377

Description

@vandenheuvel

A small demo:

#[derive(PartialEq, Eq, Clone, Copy)]
enum X { A, B, C, }

fn main() {
  match (X::A, Some(X::A)) {
    (_, None) => false,
    (v, Some(w)) if v == w => true,
    (X::B, Some(X::C)) => false,
    (X::B, Some(X::A)) => false,
    (X::A, Some(X::C)) | (X::C, Some(X::A)) => false,
  };
}

Playground.

I expected to see this happen
The usual error message indicating that patterns (A, Some(B)) and (C, Some(B)) are not covered.

Instead, this happened
Patterns (A, Some(A)) and (A, Some(B)) are detected as not covered.

rustc --version --verbose:

rustc 1.45.0-nightly (a74d1862d 2020-05-14)
binary: rustc
commit-hash: a74d1862d4d87a56244958416fd05976c58ca1a8
commit-date: 2020-05-14
host: x86_64-unknown-linux-gnu
release: 1.45.0-nightly
LLVM version: 9.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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.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