]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/const-eval/validate_uninhabited_zsts.rs
Rollup merge of #86424 - calebcartwright:rustfmt-mod-resolution, r=Mark-Simulacrum
[rust.git] / src / test / ui / consts / const-eval / validate_uninhabited_zsts.rs
1 // stderr-per-bitwidth
2 #![feature(const_fn_transmute)]
3
4 const fn foo() -> ! {
5     unsafe { std::mem::transmute(()) }
6     //~^ ERROR evaluation of constant value failed
7     //~| WARN the type `!` does not permit zero-initialization [invalid_value]
8 }
9
10 #[derive(Clone, Copy)]
11 enum Empty { }
12
13 #[warn(const_err)]
14 const FOO: [Empty; 3] = [foo(); 3];
15
16 #[warn(const_err)]
17 const BAR: [Empty; 3] = [unsafe { std::mem::transmute(()) }; 3];
18 //~^ ERROR it is undefined behavior to use this value
19 //~| WARN the type `Empty` does not permit zero-initialization
20
21 fn main() {
22     FOO;
23     BAR;
24 }