rust/tests/compile-fail/never_transmute_humans.rs

18 lines
340 B
Rust
Raw Normal View History

2017-09-22 06:21:30 -05:00
// 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 entered unreachable code
};
f(x)
}
fn f(x: !) -> ! { x }