rust/tests/fail/never_transmute_void.rs
2022-07-08 16:08:32 +00:00

20 lines
405 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`
}