fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #69444 - pietroalbini:stable-next-final-v2-new, r=pietroalbinif3e1a954d2e

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