rust/tests/compile-fail/never_transmute_void.rs
2022-04-20 17:46:31 -04:00

22 lines
417 B
Rust

// This should fail even without validation
// compile-flags: -Zmiri-disable-validation
#![feature(never_type)]
#![allow(unused, invalid_value)]
mod m {
enum VoidI {}
pub struct Void(VoidI);
pub fn f(v: Void) -> ! {
match v.0 {} //~ ERROR entering unreachable code
}
}
fn main() {
let v = unsafe {
std::mem::transmute::<(), m::Void>(())
};
m::f(v); //~ inside `main`
}