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 0x00000001, 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: 4, align: 4) {
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 = 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
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 0x00000000, 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: 4, align: 4) {
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 = 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
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 = 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
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 = 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
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 = 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
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 = 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