rust/tests/compile-fail/never_transmute_void.rs

19 lines
346 B
Rust
Raw Normal View History

2017-09-22 06:21:30 -05:00
// This should fail even without validation
// compile-flags: -Zmiri-disable-validation
2017-09-22 06:21:30 -05:00
2017-01-12 04:23:44 -06:00
#![feature(never_type)]
2018-12-22 09:07:40 -06:00
#![allow(unused)]
2017-01-12 04:23:44 -06:00
enum Void {}
fn f(v: Void) -> ! {
2018-10-19 04:50:17 -05:00
match v {} //~ ERROR entered unreachable code
2017-01-12 04:23:44 -06:00
}
fn main() {
let v: Void = unsafe {
2017-09-22 06:21:30 -05:00
std::mem::transmute::<(), Void>(())
2017-01-12 04:23:44 -06:00
};
f(v); //~ inside call to `f`
2017-01-12 04:23:44 -06:00
}