-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-exhaustiveness-checkingRelating to exhaustiveness / usefulness checking of patternsRelating to exhaustiveness / usefulness checking of patternsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
The following code generates a warning:
fn main() {
#[derive(Copy, Clone)]
enum Void {}
union Uninit<T: Copy> {
value: T,
uninit: (),
}
unsafe {
let x: Uninit<Void> = Uninit { uninit: () };
match x.value {
_ => println!("hi from the void!"),
}
}
}
warning: unreachable pattern
--> src/main.rs:12:13
|
12 | _ => println!("hi from the void!"),
| ^
|
= note: `#[warn(unreachable_patterns)]` on by default
This warning is wrong: running the code in Miri shows that this arm is reachable and there is no UB.
Metadata
Metadata
Assignees
Labels
A-exhaustiveness-checkingRelating to exhaustiveness / usefulness checking of patternsRelating to exhaustiveness / usefulness checking of patternsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.