Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

or_patterns: incorrect unreachable pattern warning #71977

Closed
lcnr opened this issue May 7, 2020 · 0 comments · Fixed by #73973
Closed

or_patterns: incorrect unreachable pattern warning #71977

lcnr opened this issue May 7, 2020 · 0 comments · Fixed by #73973
Labels
A-exhaustiveness-checking Relating to exhaustiveness / usefulness checking of patterns C-bug Category: This is a bug. F-or_patterns `#![feature(or_patterns)]` requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@lcnr
Copy link
Contributor

lcnr commented May 7, 2020

#![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

@lcnr lcnr added the C-bug Category: This is a bug. label May 7, 2020
@jonas-schievink jonas-schievink added F-or_patterns `#![feature(or_patterns)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. requires-nightly This issue requires a nightly compiler in some way. labels May 7, 2020
@jonas-schievink jonas-schievink added the A-exhaustiveness-checking Relating to exhaustiveness / usefulness checking of patterns label May 22, 2020
Manishearth added a commit to Manishearth/rust that referenced this issue Jul 5, 2020
Use `Span`s to identify unreachable subpatterns in or-patterns

Fixes rust-lang#71977
@bors bors closed this as completed in 3cb31b6 Jul 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-exhaustiveness-checking Relating to exhaustiveness / usefulness checking of patterns C-bug Category: This is a bug. F-or_patterns `#![feature(or_patterns)]` requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants