]> git.proxmox.com Git - rustc.git/blob - src/test/ui/consts/const_unsafe_unreachable_ub.rs
New upstream version 1.53.0+dfsg1
[rustc.git] / src / test / ui / consts / const_unsafe_unreachable_ub.rs
1 // build-fail
2
3 #![feature(const_unreachable_unchecked)]
4
5 const unsafe fn foo(x: bool) -> bool {
6 match x {
7 true => true,
8 false => std::hint::unreachable_unchecked(),
9 }
10 }
11
12 #[warn(const_err)]
13 const BAR: bool = unsafe { foo(false) };
14
15 fn main() {
16 assert_eq!(BAR, true);
17 //~^ ERROR E0080
18 //~| ERROR erroneous constant
19 //~| WARN this was previously accepted by the compiler but is being phased out
20 }