1 error[E0080]: it is undefined behavior to use this value
2 --> $DIR/ub-enum.rs:24:1
4 LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) };
5 | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered 0x0000000000000001, but expected a valid enum tag
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: 8, align: 8) {
9 01 00 00 00 00 00 00 00 │ ........
12 error: any use of this value will cause an error
13 --> $DIR/ub-enum.rs:27:1
15 LL | const BAD_ENUM_PTR: Enum = unsafe { mem::transmute(&1) };
16 | ^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
18 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
19 = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
20 = help: this code performed an operation that depends on the underlying bytes representing a pointer
21 = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
22 = note: `#[deny(const_err)]` on by default
24 error: any use of this value will cause an error
25 --> $DIR/ub-enum.rs:31:1
27 LL | const BAD_ENUM_WRAPPED: Wrap<Enum> = unsafe { mem::transmute(&1) };
28 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
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
35 error[E0080]: it is undefined behavior to use this value
36 --> $DIR/ub-enum.rs:44:1
38 LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) };
39 | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered 0x0000000000000000, but expected a valid enum tag
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: 8, align: 8) {
43 00 00 00 00 00 00 00 00 │ ........
46 error: any use of this value will cause an error
47 --> $DIR/ub-enum.rs:46:1
49 LL | const BAD_ENUM2_PTR: Enum2 = unsafe { mem::transmute(&0) };
50 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
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
57 error: any use of this value will cause an error
58 --> $DIR/ub-enum.rs:50:1
60 LL | const BAD_ENUM2_WRAPPED: Wrap<Enum2> = unsafe { mem::transmute(&0) };
61 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
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
68 error[E0080]: evaluation of constant value failed
69 --> $DIR/ub-enum.rs:60:42
71 LL | const BAD_ENUM2_UNDEF : Enum2 = unsafe { MaybeUninit { uninit: () }.init };
72 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
74 error: any use of this value will cause an error
75 --> $DIR/ub-enum.rs:65:1
77 LL | const BAD_ENUM2_OPTION_PTR: Option<Enum2> = unsafe { mem::transmute(&0) };
78 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
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
85 error[E0080]: it is undefined behavior to use this value
86 --> $DIR/ub-enum.rs:83:1
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 `!`
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) {
96 error[E0080]: it is undefined behavior to use this value
97 --> $DIR/ub-enum.rs:85:1
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
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) {
107 error[E0080]: it is undefined behavior to use this value
108 --> $DIR/ub-enum.rs:93:1
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`)
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.......
118 error[E0080]: evaluation of constant value failed
119 --> $DIR/ub-enum.rs:98:77
121 LL | const BAD_UNINHABITED_WITH_DATA1: Result<(i32, Never), (i32, !)> = unsafe { mem::transmute(0u64) };
122 | ^^^^^^^^^^^^^^^^^^^^ transmuting to uninhabited type
124 error[E0080]: evaluation of constant value failed
125 --> $DIR/ub-enum.rs:100:77
127 LL | const BAD_UNINHABITED_WITH_DATA2: Result<(i32, !), (i32, Never)> = unsafe { mem::transmute(0u64) };
128 | ^^^^^^^^^^^^^^^^^^^^ transmuting to uninhabited type
130 error: aborting due to 13 previous errors
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
137 LL | const BAD_ENUM_PTR: Enum = unsafe { mem::transmute(&1) };
138 | ^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
140 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
141 = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
142 = help: this code performed an operation that depends on the underlying bytes representing a pointer
143 = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
144 = note: `#[deny(const_err)]` on by default
146 Future breakage diagnostic:
147 error: any use of this value will cause an error
148 --> $DIR/ub-enum.rs:31:1
150 LL | const BAD_ENUM_WRAPPED: Wrap<Enum> = unsafe { mem::transmute(&1) };
151 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
153 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
154 = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
155 = help: this code performed an operation that depends on the underlying bytes representing a pointer
156 = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
157 = note: `#[deny(const_err)]` on by default
159 Future breakage diagnostic:
160 error: any use of this value will cause an error
161 --> $DIR/ub-enum.rs:46:1
163 LL | const BAD_ENUM2_PTR: Enum2 = unsafe { mem::transmute(&0) };
164 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
166 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
167 = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
168 = help: this code performed an operation that depends on the underlying bytes representing a pointer
169 = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
170 = note: `#[deny(const_err)]` on by default
172 Future breakage diagnostic:
173 error: any use of this value will cause an error
174 --> $DIR/ub-enum.rs:50:1
176 LL | const BAD_ENUM2_WRAPPED: Wrap<Enum2> = unsafe { mem::transmute(&0) };
177 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
179 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
180 = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
181 = help: this code performed an operation that depends on the underlying bytes representing a pointer
182 = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
183 = note: `#[deny(const_err)]` on by default
185 Future breakage diagnostic:
186 error: any use of this value will cause an error
187 --> $DIR/ub-enum.rs:65:1
189 LL | const BAD_ENUM2_OPTION_PTR: Option<Enum2> = unsafe { mem::transmute(&0) };
190 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
192 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
193 = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
194 = help: this code performed an operation that depends on the underlying bytes representing a pointer
195 = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
196 = note: `#[deny(const_err)]` on by default