2019-12-27 13:33:22 -06:00
|
|
|
#![feature(const_fn)]
|
2019-08-29 19:01:04 -05:00
|
|
|
#![feature(const_fn_transmute)]
|
2019-12-27 13:33:22 -06:00
|
|
|
|
|
|
|
const fn foo() -> ! {
|
|
|
|
unsafe { std::mem::transmute(()) }
|
|
|
|
//~^ WARN any use of this value will cause an error [const_err]
|
|
|
|
//~| WARN the type `!` does not permit zero-initialization [invalid_value]
|
2021-01-30 07:49:22 -06:00
|
|
|
//~| WARN this was previously accepted by the compiler but is being phased out
|
2019-12-27 13:33:22 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Copy)]
|
|
|
|
enum Empty { }
|
|
|
|
|
|
|
|
#[warn(const_err)]
|
|
|
|
const FOO: [Empty; 3] = [foo(); 3];
|
|
|
|
|
|
|
|
#[warn(const_err)]
|
|
|
|
const BAR: [Empty; 3] = [unsafe { std::mem::transmute(()) }; 3];
|
|
|
|
//~^ ERROR it is undefined behavior to use this value
|
|
|
|
//~| WARN the type `Empty` does not permit zero-initialization
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
FOO;
|
|
|
|
BAR;
|
|
|
|
}
|