about summary refs log tree commit diff
path: root/tests/ui/raw-ref-op/never-place-isnt-diverging.rs
blob: 80d441729f746a29f09ccf896714f2c2fda07d0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#![feature(never_type)]

fn make_up_a_value<T>() -> T {
    unsafe {
    //~^ ERROR mismatched types
        let x: *const ! = 0 as _;
        &raw const *x;
        // Since `*x` is `!`, HIR typeck used to think that it diverges
        // and allowed the block to coerce to any value, leading to UB.
    }
}


fn make_up_a_pointer<T>() -> *const T {
    unsafe {
        let x: *const ! = 0 as _;
        &raw const *x
        //~^ ERROR mismatched types
    }
}

fn main() {}