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

Incorrect "unreachable pattern" warning #79498

Closed
psychon opened this issue Nov 28, 2020 · 3 comments
Closed

Incorrect "unreachable pattern" warning #79498

psychon opened this issue Nov 28, 2020 · 3 comments
Labels
I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-release Relevant to the release subteam, which will review and decide on the PR/issue.
Milestone

Comments

@psychon
Copy link

psychon commented Nov 28, 2020

Hi,

the following program builds without warnings on stable and nightly, but prints an (IMHO incorrect) warning on beta:

fn foo() -> (Result<u8, ()>, &'static [u8]) {
    (Err(()), b"1")
}

fn main() {
    match foo() {
        (Ok(_), _) => panic!("1"),
        (Err(_), b"") => panic!("2"),
        (Err(_), _) => panic!("3"),
    }
}

(Playground)

Errors:

   Compiling playground v0.0.1 (/playground)
warning: unreachable pattern
 --> src/main.rs:9:9
  |
9 |         (Err(_), _) => panic!("3"),
  |         ^^^^^^^^^^^
  |
  = note: `#[warn(unreachable_patterns)]` on by default

warning: 1 warning emitted

    Finished dev [unoptimized + debuginfo] target(s) in 1.46s
     Running `target/debug/playground`
thread 'main' panicked at '3', src/main.rs:9:24
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

The panic shows that the supposedly unreachable pattern was, well, reached.

Originally discovered in psychon/x11rb#561 and surprisingly my attempt at reducing the example succeeded on the first try.

@sfackler
Copy link
Member

This seems like #79048. It looks like the fix for that didn't make it into the beta branch.

@sfackler sfackler added I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness regression-from-stable-to-beta Performance or correctness regression from stable to beta. labels Nov 28, 2020
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Nov 28, 2020
@jyn514 jyn514 added the T-release Relevant to the release subteam, which will review and decide on the PR/issue. label Nov 28, 2020
@jyn514
Copy link
Member

jyn514 commented Nov 28, 2020

#79072 was beta nominated, I think there just hasn't been a compiler meeting since because of the US holiday.

psychon added a commit to psychon/x11rb that referenced this issue Nov 28, 2020
[0] triggers a false-positive that prevents progress. Since I have no
good idea what to do about that, my bad idea is to just disable this
part of CI:

[0]: #561
[1]: rust-lang/rust#79498

Signed-off-by: Uli Schlachter <psychon@znc.in>
@Mark-Simulacrum Mark-Simulacrum added this to the 1.49.0 milestone Dec 11, 2020
@Mark-Simulacrum
Copy link
Member

Closing as fixed on master/beta.

@jyn514 jyn514 removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Feb 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-release Relevant to the release subteam, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants