]> git.proxmox.com Git - rustc.git/blame - src/test/ui/consts/const-eval/validate_uninhabited_zsts.rs
New upstream version 1.56.0~beta.4+dfsg1
[rustc.git] / src / test / ui / consts / const-eval / validate_uninhabited_zsts.rs
CommitLineData
cdc7bbd5 1// stderr-per-bitwidth
60c5eb7d
XL
2
3const fn foo() -> ! {
4 unsafe { std::mem::transmute(()) }
136023e0 5 //~^ ERROR evaluation of constant value failed
60c5eb7d
XL
6 //~| WARN the type `!` does not permit zero-initialization [invalid_value]
7}
8
9#[derive(Clone, Copy)]
10enum Empty { }
11
12#[warn(const_err)]
13const FOO: [Empty; 3] = [foo(); 3];
dfeec247 14
60c5eb7d
XL
15#[warn(const_err)]
16const BAR: [Empty; 3] = [unsafe { std::mem::transmute(()) }; 3];
17//~^ ERROR it is undefined behavior to use this value
18//~| WARN the type `Empty` does not permit zero-initialization
19
20fn main() {
21 FOO;
22 BAR;
23}