|
| 1 | +warning: any use of this value will cause an error |
| 2 | + --> $DIR/validate_uninhabited_zsts.rs:5:14 |
| 3 | + | |
| 4 | +LL | unsafe { std::mem::transmute(()) } |
| 5 | + | ^^^^^^^^^^^^^^^^^^^^^^^ |
| 6 | + | | |
| 7 | + | entering unreachable code |
| 8 | + | inside call to `foo` at $DIR/validate_uninhabited_zsts.rs:14:26 |
| 9 | +... |
| 10 | +LL | const FOO: [Empty; 3] = [foo(); 3]; |
| 11 | + | ----------------------------------- |
| 12 | + | |
| 13 | +note: lint level defined here |
| 14 | + --> $DIR/validate_uninhabited_zsts.rs:13:8 |
| 15 | + | |
| 16 | +LL | #[warn(const_err)] |
| 17 | + | ^^^^^^^^^ |
| 18 | + |
| 19 | +error[E0080]: it is undefined behavior to use this value |
| 20 | + --> $DIR/validate_uninhabited_zsts.rs:17:1 |
| 21 | + | |
| 22 | +LL | const BAR: [Empty; 3] = [unsafe { std::mem::transmute(()) }; 3]; |
| 23 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a value of an uninhabited type |
| 24 | + | |
| 25 | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 26 | + |
| 27 | +warning: the type `!` does not permit zero-initialization |
| 28 | + --> $DIR/validate_uninhabited_zsts.rs:5:14 |
| 29 | + | |
| 30 | +LL | unsafe { std::mem::transmute(()) } |
| 31 | + | ^^^^^^^^^^^^^^^^^^^^^^^ |
| 32 | + | | |
| 33 | + | this code causes undefined behavior when executed |
| 34 | + | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done |
| 35 | + | |
| 36 | + = note: `#[warn(invalid_value)]` on by default |
| 37 | + = note: The never type (`!`) has no valid value |
| 38 | + |
| 39 | +warning: the type `Empty` does not permit zero-initialization |
| 40 | + --> $DIR/validate_uninhabited_zsts.rs:17:35 |
| 41 | + | |
| 42 | +LL | const BAR: [Empty; 3] = [unsafe { std::mem::transmute(()) }; 3]; |
| 43 | + | ^^^^^^^^^^^^^^^^^^^^^^^ |
| 44 | + | | |
| 45 | + | this code causes undefined behavior when executed |
| 46 | + | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done |
| 47 | + | |
| 48 | + = note: 0-variant enums have no valid value |
| 49 | + |
| 50 | +error: aborting due to previous error |
| 51 | + |
| 52 | +For more information about this error, try `rustc --explain E0080`. |
0 commit comments