]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/const-eval/ub-enum.32bit.stderr
also query type_uninhabited_from
[rust.git] / src / test / ui / consts / const-eval / ub-enum.32bit.stderr
1 error[E0080]: it is undefined behavior to use this value
2   --> $DIR/ub-enum.rs:24:1
3    |
4 LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) };
5    | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered 0x00000001, but expected a valid enum tag
6    |
7    = 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.
8    = note: the raw bytes of the constant (size: 4, align: 4) {
9                01 00 00 00                                     │ ....
10            }
11
12 error: any use of this value will cause an error
13   --> $DIR/ub-enum.rs:27:1
14    |
15 LL | const BAD_ENUM_PTR: Enum = unsafe { mem::transmute(&1) };
16    | ^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
17    |
18    = note: `#[deny(const_err)]` on by default
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    = help: this code performed an operation that depends on the underlying bytes representing a pointer
22    = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
23
24 error: any use of this value will cause an error
25   --> $DIR/ub-enum.rs:31:1
26    |
27 LL | const BAD_ENUM_WRAPPED: Wrap<Enum> = unsafe { mem::transmute(&1) };
28    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
29    |
30    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
31    = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
32    = help: this code performed an operation that depends on the underlying bytes representing a pointer
33    = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
34
35 error[E0080]: it is undefined behavior to use this value
36   --> $DIR/ub-enum.rs:44:1
37    |
38 LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) };
39    | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered 0x00000000, but expected a valid enum tag
40    |
41    = 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.
42    = note: the raw bytes of the constant (size: 4, align: 4) {
43                00 00 00 00                                     │ ....
44            }
45
46 error: any use of this value will cause an error
47   --> $DIR/ub-enum.rs:46:1
48    |
49 LL | const BAD_ENUM2_PTR: Enum2 = unsafe { mem::transmute(&0) };
50    | ^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
51    |
52    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
53    = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
54    = help: this code performed an operation that depends on the underlying bytes representing a pointer
55    = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
56
57 error: any use of this value will cause an error
58   --> $DIR/ub-enum.rs:50:1
59    |
60 LL | const BAD_ENUM2_WRAPPED: Wrap<Enum2> = unsafe { mem::transmute(&0) };
61    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
62    |
63    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
64    = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
65    = help: this code performed an operation that depends on the underlying bytes representing a pointer
66    = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
67
68 error[E0080]: evaluation of constant value failed
69   --> $DIR/ub-enum.rs:60:42
70    |
71 LL | const BAD_ENUM2_UNDEF : Enum2 = unsafe { MaybeUninit { uninit: () }.init };
72    |                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
73
74 error: any use of this value will cause an error
75   --> $DIR/ub-enum.rs:65:1
76    |
77 LL | const BAD_ENUM2_OPTION_PTR: Option<Enum2> = unsafe { mem::transmute(&0) };
78    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
79    |
80    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
81    = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
82    = help: this code performed an operation that depends on the underlying bytes representing a pointer
83    = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
84
85 error[E0080]: it is undefined behavior to use this value
86   --> $DIR/ub-enum.rs:83:1
87    |
88 LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute(1u8) };
89    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(B)>.0: encountered a value of the never type `!`
90    |
91    = 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.
92    = note: the raw bytes of the constant (size: 1, align: 1) {
93                01                                              │ .
94            }
95
96 error[E0080]: it is undefined behavior to use this value
97   --> $DIR/ub-enum.rs:85:1
98    |
99 LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) };
100    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(D)>.0: encountered a value of uninhabited type Never
101    |
102    = 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.
103    = note: the raw bytes of the constant (size: 1, align: 1) {
104                03                                              │ .
105            }
106
107 error[E0080]: it is undefined behavior to use this value
108   --> $DIR/ub-enum.rs:93:1
109    |
110 LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::transmute(!0u32) }));
111    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(Some)>.0.1: encountered 0xffffffff, but expected a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`)
112    |
113    = 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.
114    = note: the raw bytes of the constant (size: 8, align: 4) {
115                78 00 00 00 ff ff ff ff                         │ x.......
116            }
117
118 error[E0080]: evaluation of constant value failed
119   --> $DIR/ub-enum.rs:98:77
120    |
121 LL | const BAD_UNINHABITED_WITH_DATA1: Result<(i32, Never), (i32, !)> = unsafe { mem::transmute(0u64) };
122    |                                                                             ^^^^^^^^^^^^^^^^^^^^ transmuting to uninhabited type
123
124 error[E0080]: evaluation of constant value failed
125   --> $DIR/ub-enum.rs:100:77
126    |
127 LL | const BAD_UNINHABITED_WITH_DATA2: Result<(i32, !), (i32, Never)> = unsafe { mem::transmute(0u64) };
128    |                                                                             ^^^^^^^^^^^^^^^^^^^^ transmuting to uninhabited type
129
130 error: aborting due to 13 previous errors
131
132 For more information about this error, try `rustc --explain E0080`.
133 Future incompatibility report: Future breakage diagnostic:
134 error: any use of this value will cause an error
135   --> $DIR/ub-enum.rs:27:1
136    |
137 LL | const BAD_ENUM_PTR: Enum = unsafe { mem::transmute(&1) };
138    | ^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
139    |
140    = note: `#[deny(const_err)]` on by default
141    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
142    = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
143    = help: this code performed an operation that depends on the underlying bytes representing a pointer
144    = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
145
146 Future breakage diagnostic:
147 error: any use of this value will cause an error
148   --> $DIR/ub-enum.rs:31:1
149    |
150 LL | const BAD_ENUM_WRAPPED: Wrap<Enum> = unsafe { mem::transmute(&1) };
151    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
152    |
153    = note: `#[deny(const_err)]` on by default
154    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
155    = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
156    = help: this code performed an operation that depends on the underlying bytes representing a pointer
157    = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
158
159 Future breakage diagnostic:
160 error: any use of this value will cause an error
161   --> $DIR/ub-enum.rs:46:1
162    |
163 LL | const BAD_ENUM2_PTR: Enum2 = unsafe { mem::transmute(&0) };
164    | ^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
165    |
166    = note: `#[deny(const_err)]` on by default
167    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
168    = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
169    = help: this code performed an operation that depends on the underlying bytes representing a pointer
170    = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
171
172 Future breakage diagnostic:
173 error: any use of this value will cause an error
174   --> $DIR/ub-enum.rs:50:1
175    |
176 LL | const BAD_ENUM2_WRAPPED: Wrap<Enum2> = unsafe { mem::transmute(&0) };
177    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
178    |
179    = note: `#[deny(const_err)]` on by default
180    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
181    = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
182    = help: this code performed an operation that depends on the underlying bytes representing a pointer
183    = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
184
185 Future breakage diagnostic:
186 error: any use of this value will cause an error
187   --> $DIR/ub-enum.rs:65:1
188    |
189 LL | const BAD_ENUM2_OPTION_PTR: Option<Enum2> = unsafe { mem::transmute(&0) };
190    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
191    |
192    = note: `#[deny(const_err)]` on by default
193    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
194    = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
195    = help: this code performed an operation that depends on the underlying bytes representing a pointer
196    = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
197