]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/const-eval/validate_uninhabited_zsts.32bit.stderr
Rollup merge of #83634 - JohnTitor:proc-macro-ice, r=varkor
[rust.git] / src / test / ui / consts / const-eval / validate_uninhabited_zsts.32bit.stderr
1 warning: any use of this value will cause an error
2   --> $DIR/validate_uninhabited_zsts.rs:6:14
3    |
4 LL |     unsafe { std::mem::transmute(()) }
5    |              ^^^^^^^^^^^^^^^^^^^^^^^
6    |              |
7    |              transmuting to uninhabited type
8    |              inside `foo` at $DIR/validate_uninhabited_zsts.rs:6:14
9    |              inside `FOO` at $DIR/validate_uninhabited_zsts.rs:16:26
10 ...
11 LL | const FOO: [Empty; 3] = [foo(); 3];
12    | -----------------------------------
13    |
14 note: the lint level is defined here
15   --> $DIR/validate_uninhabited_zsts.rs:15:8
16    |
17 LL | #[warn(const_err)]
18    |        ^^^^^^^^^
19    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
20    = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
21
22 error[E0080]: it is undefined behavior to use this value
23   --> $DIR/validate_uninhabited_zsts.rs:19:1
24    |
25 LL | const BAR: [Empty; 3] = [unsafe { std::mem::transmute(()) }; 3];
26    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a value of uninhabited type Empty at [0]
27    |
28    = 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.
29    = note: the raw bytes of the constant (size: 0, align: 1) {}
30
31 warning: the type `!` does not permit zero-initialization
32   --> $DIR/validate_uninhabited_zsts.rs:6:14
33    |
34 LL |     unsafe { std::mem::transmute(()) }
35    |              ^^^^^^^^^^^^^^^^^^^^^^^
36    |              |
37    |              this code causes undefined behavior when executed
38    |              help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
39    |
40    = note: `#[warn(invalid_value)]` on by default
41    = note: the `!` type has no valid value
42
43 warning: the type `Empty` does not permit zero-initialization
44   --> $DIR/validate_uninhabited_zsts.rs:19:35
45    |
46 LL | const BAR: [Empty; 3] = [unsafe { std::mem::transmute(()) }; 3];
47    |                                   ^^^^^^^^^^^^^^^^^^^^^^^
48    |                                   |
49    |                                   this code causes undefined behavior when executed
50    |                                   help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
51    |
52    = note: enums with no variants have no valid value
53
54 error: aborting due to previous error; 3 warnings emitted
55
56 For more information about this error, try `rustc --explain E0080`.