rust/tests/compile-fail/never_transmute_humans.rs
2018-06-05 18:08:18 +02:00

19 lines
392 B
Rust

// This should fail even without validation
// compile-flags: -Zmir-emit-validate=0
#![feature(never_type)]
#![allow(unreachable_code)]
#![allow(unused_variables)]
struct Human;
fn main() {
let x: ! = unsafe {
std::mem::transmute::<Human, !>(Human) //~ ERROR constant evaluation error [E0080]
//^~ NOTE entered unreachable code
};
f(x)
}
fn f(x: !) -> ! { x }