Closed
Description
I tried this code:
pub fn parse_data(data: &[u8]) -> u32 {
match data {
b"" => 1,
_ => 2,
}
}
fn main() {
println!("{}", parse_data(b"asd"))
}
It produces the following, incorrect, warning:
warning: unreachable pattern
--> src/main.rs:4:9
|
4 | _ => 2,
| ^
|
= note: `#[warn(unreachable_patterns)]` on by default
however, the output is 2
so it's clearly incorrect
Meta
rustc --version
:
1.50.0-nightly (2020-11-13 74f7e32f43b5fb0f8389)
Metadata
Metadata
Assignees
Labels
Relating to exhaustiveness / usefulness checking of patternsCategory: This is a bug.Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessCritical priorityRelevant to the compiler team, which will review and decide on the PR/issue.Performance or correctness regression from stable to nightly.