]> git.lizzy.rs Git - rust.git/blob - tests/ui/statics/uninhabited-static.stderr
Rollup merge of #106397 - compiler-errors:new-solver-impl-wc, r=lcnr
[rust.git] / tests / 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    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
8    = note: for more information, see issue #74840 <https://github.com/rust-lang/rust/issues/74840>
9    = note: uninhabited statics cannot be initialized, and any access would be an immediate error
10 note: the lint level is defined here
11   --> $DIR/uninhabited-static.rs:2:9
12    |
13 LL | #![deny(uninhabited_static)]
14    |         ^^^^^^^^^^^^^^^^^^
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]: could not evaluate static initializer
47   --> $DIR/uninhabited-static.rs:12:31
48    |
49 LL | static VOID2: Void = unsafe { std::mem::transmute(()) };
50    |                               ^^^^^^^^^^^^^^^^^^^^^^^ transmuting to uninhabited type
51
52 warning: the type `Void` does not permit zero-initialization
53   --> $DIR/uninhabited-static.rs:12:31
54    |
55 LL | static VOID2: Void = unsafe { std::mem::transmute(()) };
56    |                               ^^^^^^^^^^^^^^^^^^^^^^^
57    |                               |
58    |                               this code causes undefined behavior when executed
59    |                               help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
60    |
61 note: enums with no inhabited variants have no valid value
62   --> $DIR/uninhabited-static.rs:4:1
63    |
64 LL | enum Void {}
65    | ^^^^^^^^^
66    = note: `#[warn(invalid_value)]` on by default
67
68 error[E0080]: could not evaluate static initializer
69   --> $DIR/uninhabited-static.rs:16:32
70    |
71 LL | static NEVER2: Void = unsafe { std::mem::transmute(()) };
72    |                                ^^^^^^^^^^^^^^^^^^^^^^^ transmuting to uninhabited type
73
74 warning: the type `Void` does not permit zero-initialization
75   --> $DIR/uninhabited-static.rs:16:32
76    |
77 LL | static NEVER2: Void = unsafe { std::mem::transmute(()) };
78    |                                ^^^^^^^^^^^^^^^^^^^^^^^
79    |                                |
80    |                                this code causes undefined behavior when executed
81    |                                help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
82    |
83 note: enums with no inhabited variants have no valid value
84   --> $DIR/uninhabited-static.rs:4:1
85    |
86 LL | enum Void {}
87    | ^^^^^^^^^
88
89 error: aborting due to 6 previous errors; 2 warnings emitted
90
91 For more information about this error, try `rustc --explain E0080`.