]> git.lizzy.rs Git - rust.git/blob - tests/compile-fail/never_transmute_void.rs
rustup
[rust.git] / tests / compile-fail / never_transmute_void.rs
1 // This should fail even without validation
2 // compile-flags: -Zmiri-disable-validation
3
4 #![feature(never_type)]
5 #![allow(unused, invalid_value)]
6
7 mod m {
8     enum VoidI {}
9     pub struct Void(VoidI);
10
11     pub fn f(v: Void) -> ! {
12         match v.0 {} //~ ERROR entering unreachable code
13     }
14 }
15
16 fn main() {
17     let v = unsafe {
18         std::mem::transmute::<(), m::Void>(())
19     };
20     m::f(v); //~ inside `main`
21 }