]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/const-eval/validate_uninhabited_zsts.rs
Rollup merge of #80733 - steffahn:prettify_pin_links, r=jyn514
[rust.git] / src / test / ui / consts / const-eval / validate_uninhabited_zsts.rs
1 // stderr-per-bitwidth
2 #![feature(const_fn)]
3 #![feature(const_fn_transmute)]
4
5 const fn foo() -> ! {
6     unsafe { std::mem::transmute(()) }
7     //~^ WARN any use of this value will cause an error [const_err]
8     //~| WARN the type `!` does not permit zero-initialization [invalid_value]
9     //~| WARN this was previously accepted by the compiler but is being phased out
10 }
11
12 #[derive(Clone, Copy)]
13 enum Empty { }
14
15 #[warn(const_err)]
16 const FOO: [Empty; 3] = [foo(); 3];
17
18 #[warn(const_err)]
19 const BAR: [Empty; 3] = [unsafe { std::mem::transmute(()) }; 3];
20 //~^ ERROR it is undefined behavior to use this value
21 //~| WARN the type `Empty` does not permit zero-initialization
22
23 fn main() {
24     FOO;
25     BAR;
26 }