2021-03-31 03:09:16 -05:00
|
|
|
// stderr-per-bitwidth
|
2019-12-27 13:33:22 -06:00
|
|
|
|
|
|
|
const fn foo() -> ! {
|
|
|
|
unsafe { std::mem::transmute(()) }
|
2021-06-18 12:31:56 -05:00
|
|
|
//~^ ERROR evaluation of constant value failed
|
2019-12-27 13:33:22 -06:00
|
|
|
//~| WARN the type `!` does not permit zero-initialization [invalid_value]
|
|
|
|
}
|
|
|
|
|
2022-04-20 19:00:00 -05:00
|
|
|
// Type defined in a submodule, so that it is not "visibly"
|
|
|
|
// uninhabited (which would change interpreter behavior).
|
|
|
|
pub mod empty {
|
|
|
|
#[derive(Clone, Copy)]
|
|
|
|
enum Void {}
|
|
|
|
|
|
|
|
#[derive(Clone, Copy)]
|
|
|
|
pub struct Empty(Void);
|
|
|
|
}
|
2019-12-27 13:33:22 -06:00
|
|
|
|
2022-04-20 19:00:00 -05:00
|
|
|
const FOO: [empty::Empty; 3] = [foo(); 3];
|
2019-12-27 13:33:22 -06:00
|
|
|
|
2022-04-20 19:00:00 -05:00
|
|
|
const BAR: [empty::Empty; 3] = [unsafe { std::mem::transmute(()) }; 3];
|
|
|
|
//~^ ERROR it is undefined behavior to use this value
|
|
|
|
//~| WARN the type `empty::Empty` does not permit zero-initialization
|
2019-12-27 13:33:22 -06:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
FOO;
|
|
|
|
BAR;
|
|
|
|
}
|