-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessT-releaseRelevant to the release subteam, which will review and decide on the PR/issue.Relevant to the release subteam, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.Performance or correctness regression from stable to beta.
Milestone
Description
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"),
}
}
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.
Metadata
Metadata
Assignees
Labels
I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessT-releaseRelevant to the release subteam, which will review and decide on the PR/issue.Relevant to the release subteam, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.Performance or correctness regression from stable to beta.