summaryrefslogtreecommitdiffstats
path: root/tests/ui/never_type/never_transmute_never.rs
blob: fce3ced9aac7fc58f4e8bfcbfaae77559a177ed9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// check-pass

#![crate_type="lib"]

#![feature(never_type)]
#![allow(dead_code)]
#![allow(unreachable_code)]
#![allow(unused_variables)]

struct Foo;

pub fn f(x: !) -> ! {
    x
}

pub fn ub() {
    // This is completely undefined behaviour,
    // but we still want to make sure it compiles.
    let x: ! = unsafe {
        std::mem::transmute::<Foo, !>(Foo)
    };
    f(x)
}