about summary refs log tree commit diff
path: root/tests/ui/consts/const_unsafe_unreachable_ub.rs
blob: 39f053951276ed77a76edb816c0fc819efc799ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
const unsafe fn foo(x: bool) -> bool {
    match x {
        true => true,
        false => std::hint::unreachable_unchecked(),
        //~^ NOTE inside `foo`
        //~| NOTE the failure occurred here
    }
}

const BAR: bool = unsafe { foo(false) };
//~^ NOTE failed inside this call
//~| ERROR entering unreachable code

fn main() {
    assert_eq!(BAR, true);
}