rust/tests/fail/never_transmute_void.rs

22 lines
417 B
Rust
Raw Normal View History

2017-09-22 13:21:30 +02:00
// This should fail even without validation
// compile-flags: -Zmiri-disable-validation
2017-09-22 13:21:30 +02:00
#![feature(never_type)]
2019-08-18 11:16:02 +02:00
#![allow(unused, invalid_value)]
2017-01-12 11:23:44 +01:00
2022-04-20 17:41:09 -04:00
mod m {
enum VoidI {}
pub struct Void(VoidI);
2017-01-12 11:23:44 +01:00
2022-04-20 17:41:09 -04:00
pub fn f(v: Void) -> ! {
match v.0 {} //~ ERROR entering unreachable code
}
2017-01-12 11:23:44 +01:00
}
fn main() {
2022-04-20 17:41:09 -04:00
let v = unsafe {
std::mem::transmute::<(), m::Void>(())
2017-01-12 11:23:44 +01:00
};
2022-04-20 17:41:09 -04:00
m::f(v); //~ inside `main`
2017-01-12 11:23:44 +01:00
}