rust/tests/compile-fail/never_transmute_humans.rs

19 lines
384 B
Rust
Raw Normal View History

2018-05-09 10:30:16 -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 constant evaluation error
2018-05-20 08:08:15 -05:00
//^~ NOTE entered unreachable code
2018-05-09 10:30:16 -05:00
};
f(x)
}
fn f(x: !) -> ! { x }