]> git.lizzy.rs Git - rust.git/blob - src/test/ui/statics/uninhabited-static.stderr
Rollup merge of #90498 - joshtriplett:target-tier-policy-draft-updates, r=Mark-Simulacrum
[rust.git] / src / test / ui / statics / uninhabited-static.stderr
1 error: static of uninhabited type
2   --> $DIR/uninhabited-static.rs:6:5
3    |
4 LL |     static VOID: Void;
5    |     ^^^^^^^^^^^^^^^^^^
6    |
7 note: the lint level is defined here
8   --> $DIR/uninhabited-static.rs:2:9
9    |
10 LL | #![deny(uninhabited_static)]
11    |         ^^^^^^^^^^^^^^^^^^
12    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
13    = note: for more information, see issue #74840 <https://github.com/rust-lang/rust/issues/74840>
14    = note: uninhabited statics cannot be initialized, and any access would be an immediate error
15
16 error: static of uninhabited type
17   --> $DIR/uninhabited-static.rs:8:5
18    |
19 LL |     static NEVER: !;
20    |     ^^^^^^^^^^^^^^^^
21    |
22    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
23    = note: for more information, see issue #74840 <https://github.com/rust-lang/rust/issues/74840>
24    = note: uninhabited statics cannot be initialized, and any access would be an immediate error
25
26 error: static of uninhabited type
27   --> $DIR/uninhabited-static.rs:12:1
28    |
29 LL | static VOID2: Void = unsafe { std::mem::transmute(()) };
30    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
31    |
32    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
33    = note: for more information, see issue #74840 <https://github.com/rust-lang/rust/issues/74840>
34    = note: uninhabited statics cannot be initialized, and any access would be an immediate error
35
36 error: static of uninhabited type
37   --> $DIR/uninhabited-static.rs:16:1
38    |
39 LL | static NEVER2: Void = unsafe { std::mem::transmute(()) };
40    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
41    |
42    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
43    = note: for more information, see issue #74840 <https://github.com/rust-lang/rust/issues/74840>
44    = note: uninhabited statics cannot be initialized, and any access would be an immediate error
45
46 error[E0080]: it is undefined behavior to use this value
47   --> $DIR/uninhabited-static.rs:12:1
48    |
49 LL | static VOID2: Void = unsafe { std::mem::transmute(()) };
50    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a value of uninhabited type Void
51    |
52    = 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.
53    = note: the raw bytes of the constant (size: 0, align: 1) {}
54
55 error[E0080]: it is undefined behavior to use this value
56   --> $DIR/uninhabited-static.rs:16:1
57    |
58 LL | static NEVER2: Void = unsafe { std::mem::transmute(()) };
59    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a value of uninhabited type Void
60    |
61    = 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.
62    = note: the raw bytes of the constant (size: 0, align: 1) {}
63
64 warning: the type `Void` does not permit zero-initialization
65   --> $DIR/uninhabited-static.rs:12:31
66    |
67 LL | static VOID2: Void = unsafe { std::mem::transmute(()) };
68    |                               ^^^^^^^^^^^^^^^^^^^^^^^
69    |                               |
70    |                               this code causes undefined behavior when executed
71    |                               help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
72    |
73    = note: `#[warn(invalid_value)]` on by default
74    = note: enums with no variants have no valid value
75
76 warning: the type `Void` does not permit zero-initialization
77   --> $DIR/uninhabited-static.rs:16:32
78    |
79 LL | static NEVER2: Void = unsafe { std::mem::transmute(()) };
80    |                                ^^^^^^^^^^^^^^^^^^^^^^^
81    |                                |
82    |                                this code causes undefined behavior when executed
83    |                                help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
84    |
85    = note: enums with no variants have no valid value
86
87 error: aborting due to 6 previous errors; 2 warnings emitted
88
89 For more information about this error, try `rustc --explain E0080`.