Closed
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.