Skip to content

or_patterns: incorrect unreachable pattern warning #71977

Closed
@lcnr

Description

@lcnr
#![feature(or_patterns)]

enum F {
    A,
    B,
}

fn main() {
    let a = F::A;
    let b = F::B;
    match (a, b) {
        (F::A, F::A) => (),
        (F::B | F::A, F::B | F::A) => (),
    }
}

Results in the following incorrect warning:

warning: unreachable pattern
  --> src/main.rs:13:30
   |
13 |         (F::B | F::A, F::B | F::A) => (),
   |                              ^^^^
   |
   = note: `#[warn(unreachable_patterns)]` on by default

warning: 1 warning emitted

Removing F::A causes a non-exhaustive patterns error as expected.

playground

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-exhaustiveness-checkingRelating to exhaustiveness / usefulness checking of patternsC-bugCategory: This is a bug.F-or_patterns`#![feature(or_patterns)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions