11error[E0080]: it is undefined behavior to use this value
2- --> $DIR/ub-wide-ptr.rs:38 :1
2+ --> $DIR/ub-wide-ptr.rs:39 :1
33 |
44LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) };
55 | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation)
@@ -10,7 +10,7 @@ LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) };
1010 }
1111
1212error[E0080]: it is undefined behavior to use this value
13- --> $DIR/ub-wide-ptr.rs:40 :1
13+ --> $DIR/ub-wide-ptr.rs:41 :1
1414 |
1515LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, usize::MAX)) },);
1616 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered invalid reference metadata: slice is bigger than largest supported object
@@ -21,7 +21,7 @@ LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, us
2121 }
2222
2323error[E0080]: evaluation of constant value failed
24- --> $DIR/ub-wide-ptr.rs:43 :1
24+ --> $DIR/ub-wide-ptr.rs:44 :1
2525 |
2626LL | const STR_LENGTH_PTR: &str = unsafe { mem::transmute((&42u8, &3)) };
2727 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
@@ -30,7 +30,7 @@ LL | const STR_LENGTH_PTR: &str = unsafe { mem::transmute((&42u8, &3)) };
3030 = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
3131
3232error[E0080]: evaluation of constant value failed
33- --> $DIR/ub-wide-ptr.rs:46 :1
33+ --> $DIR/ub-wide-ptr.rs:47 :1
3434 |
3535LL | const MY_STR_LENGTH_PTR: &MyStr = unsafe { mem::transmute((&42u8, &3)) };
3636 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
@@ -39,7 +39,7 @@ LL | const MY_STR_LENGTH_PTR: &MyStr = unsafe { mem::transmute((&42u8, &3)) };
3939 = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
4040
4141error[E0080]: it is undefined behavior to use this value
42- --> $DIR/ub-wide-ptr.rs:48 :1
42+ --> $DIR/ub-wide-ptr.rs:49 :1
4343 |
4444LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize::MAX)) };
4545 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object
@@ -50,7 +50,7 @@ LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize:
5050 }
5151
5252error[E0080]: it is undefined behavior to use this value
53- --> $DIR/ub-wide-ptr.rs:52 :1
53+ --> $DIR/ub-wide-ptr.rs:53 :1
5454 |
5555LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) };
5656 | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>: encountered uninitialized memory, but expected a string
@@ -61,7 +61,7 @@ LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit:
6161 }
6262
6363error[E0080]: it is undefined behavior to use this value
64- --> $DIR/ub-wide-ptr.rs:55 :1
64+ --> $DIR/ub-wide-ptr.rs:56 :1
6565 |
6666LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) };
6767 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.0: encountered uninitialized memory, but expected a string
@@ -72,13 +72,13 @@ LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUni
7272 }
7373
7474error[E0080]: evaluation of constant value failed
75- --> $DIR/ub-wide-ptr.rs:62 :1
75+ --> $DIR/ub-wide-ptr.rs:63 :1
7676 |
7777LL | const SLICE_LENGTH_UNINIT: &[u8] = unsafe {
7878 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
7979
8080error[E0080]: it is undefined behavior to use this value
81- --> $DIR/ub-wide-ptr.rs:69 :1
81+ --> $DIR/ub-wide-ptr.rs:70 :1
8282 |
8383LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) };
8484 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation)
@@ -89,7 +89,7 @@ LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) };
8989 }
9090
9191error[E0080]: it is undefined behavior to use this value
92- --> $DIR/ub-wide-ptr.rs:72 :1
92+ --> $DIR/ub-wide-ptr.rs:73 :1
9393 |
9494LL | const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, isize::MAX)) };
9595 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object
@@ -100,7 +100,7 @@ LL | const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, is
100100 }
101101
102102error[E0080]: evaluation of constant value failed
103- --> $DIR/ub-wide-ptr.rs:75 :1
103+ --> $DIR/ub-wide-ptr.rs:76 :1
104104 |
105105LL | const SLICE_LENGTH_PTR: &[u8] = unsafe { mem::transmute((&42u8, &3)) };
106106 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
@@ -109,7 +109,7 @@ LL | const SLICE_LENGTH_PTR: &[u8] = unsafe { mem::transmute((&42u8, &3)) };
109109 = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
110110
111111error[E0080]: it is undefined behavior to use this value
112- --> $DIR/ub-wide-ptr.rs:78 :1
112+ --> $DIR/ub-wide-ptr.rs:79 :1
113113 |
114114LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999usize)) };
115115 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (going beyond the bounds of its allocation)
@@ -120,7 +120,7 @@ LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999us
120120 }
121121
122122error[E0080]: evaluation of constant value failed
123- --> $DIR/ub-wide-ptr.rs:81 :1
123+ --> $DIR/ub-wide-ptr.rs:82 :1
124124 |
125125LL | const SLICE_LENGTH_PTR_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, &3)) };
126126 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
@@ -129,7 +129,7 @@ LL | const SLICE_LENGTH_PTR_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, &3)
129129 = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
130130
131131error[E0080]: it is undefined behavior to use this value
132- --> $DIR/ub-wide-ptr.rs:85 :1
132+ --> $DIR/ub-wide-ptr.rs:86 :1
133133 |
134134LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }];
135135 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x03, but expected a boolean
@@ -140,13 +140,13 @@ LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }];
140140 }
141141
142142note: erroneous constant encountered
143- --> $DIR/ub-wide-ptr.rs:85 :40
143+ --> $DIR/ub-wide-ptr.rs:86 :40
144144 |
145145LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }];
146146 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
147147
148148error[E0080]: it is undefined behavior to use this value
149- --> $DIR/ub-wide-ptr.rs:92 :1
149+ --> $DIR/ub-wide-ptr.rs:93 :1
150150 |
151151LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]);
152152 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.0: encountered 0x03, but expected a boolean
@@ -157,13 +157,13 @@ LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3
157157 }
158158
159159note: erroneous constant encountered
160- --> $DIR/ub-wide-ptr.rs:92 :42
160+ --> $DIR/ub-wide-ptr.rs:93 :42
161161 |
162162LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]);
163163 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
164164
165165error[E0080]: it is undefined behavior to use this value
166- --> $DIR/ub-wide-ptr.rs:96 :1
166+ --> $DIR/ub-wide-ptr.rs:97 :1
167167 |
168168LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]);
169169 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.1[0]: encountered 0x03, but expected a boolean
@@ -174,19 +174,19 @@ LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::tran
174174 }
175175
176176note: erroneous constant encountered
177- --> $DIR/ub-wide-ptr.rs:96 :42
177+ --> $DIR/ub-wide-ptr.rs:97 :42
178178 |
179179LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]);
180180 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
181181
182182error[E0080]: evaluation of constant value failed
183- --> $DIR/ub-wide-ptr.rs:104 :1
183+ --> $DIR/ub-wide-ptr.rs:105 :1
184184 |
185185LL | const RAW_SLICE_LENGTH_UNINIT: *const [u8] = unsafe {
186186 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
187187
188188error[E0080]: it is undefined behavior to use this value
189- --> $DIR/ub-wide-ptr.rs:113 :1
189+ --> $DIR/ub-wide-ptr.rs:114 :1
190190 |
191191LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) };
192192 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC12<imm>, but expected a vtable pointer
@@ -197,7 +197,7 @@ LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((
197197 }
198198
199199error[E0080]: it is undefined behavior to use this value
200- --> $DIR/ub-wide-ptr.rs:117 :1
200+ --> $DIR/ub-wide-ptr.rs:118 :1
201201 |
202202LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) };
203203 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC14<imm>, but expected a vtable pointer
@@ -208,7 +208,7 @@ LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((
208208 }
209209
210210error[E0080]: it is undefined behavior to use this value
211- --> $DIR/ub-wide-ptr.rs:121 :1
211+ --> $DIR/ub-wide-ptr.rs:122 :1
212212 |
213213LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, 4usize))) };
214214 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered 0x4[noalloc], but expected a vtable pointer
@@ -219,7 +219,7 @@ LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u
219219 }
220220
221221error[E0080]: it is undefined behavior to use this value
222- --> $DIR/ub-wide-ptr.rs:124 :1
222+ --> $DIR/ub-wide-ptr.rs:125 :1
223223 |
224224LL | const TRAIT_OBJ_UNALIGNED_VTABLE: &dyn Trait = unsafe { mem::transmute((&92u8, &[0u8; 128])) };
225225 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC17<imm>, but expected a vtable pointer
@@ -230,7 +230,7 @@ LL | const TRAIT_OBJ_UNALIGNED_VTABLE: &dyn Trait = unsafe { mem::transmute((&92
230230 }
231231
232232error[E0080]: it is undefined behavior to use this value
233- --> $DIR/ub-wide-ptr.rs:127 :1
233+ --> $DIR/ub-wide-ptr.rs:128 :1
234234 |
235235LL | const TRAIT_OBJ_BAD_DROP_FN_NULL: &dyn Trait = unsafe { mem::transmute((&92u8, &[0usize; 8])) };
236236 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC19<imm>, but expected a vtable pointer
@@ -241,7 +241,7 @@ LL | const TRAIT_OBJ_BAD_DROP_FN_NULL: &dyn Trait = unsafe { mem::transmute((&92
241241 }
242242
243243error[E0080]: it is undefined behavior to use this value
244- --> $DIR/ub-wide-ptr.rs:130 :1
244+ --> $DIR/ub-wide-ptr.rs:131 :1
245245 |
246246LL | const TRAIT_OBJ_BAD_DROP_FN_INT: &dyn Trait = unsafe { mem::transmute((&92u8, &[1usize; 8])) };
247247 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC21<imm>, but expected a vtable pointer
@@ -252,7 +252,7 @@ LL | const TRAIT_OBJ_BAD_DROP_FN_INT: &dyn Trait = unsafe { mem::transmute((&92u
252252 }
253253
254254error[E0080]: it is undefined behavior to use this value
255- --> $DIR/ub-wide-ptr.rs:133 :1
255+ --> $DIR/ub-wide-ptr.rs:134 :1
256256 |
257257LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &[&42u8; 8]))) };
258258 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC23<imm>, but expected a vtable pointer
@@ -263,7 +263,7 @@ LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::trans
263263 }
264264
265265error[E0080]: it is undefined behavior to use this value
266- --> $DIR/ub-wide-ptr.rs:138 :1
266+ --> $DIR/ub-wide-ptr.rs:139 :1
267267 |
268268LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) };
269269 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.<dyn-downcast>: encountered 0x03, but expected a boolean
@@ -274,7 +274,7 @@ LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_,
274274 }
275275
276276error[E0080]: it is undefined behavior to use this value
277- --> $DIR/ub-wide-ptr.rs:143 :1
277+ --> $DIR/ub-wide-ptr.rs:144 :1
278278 |
279279LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) };
280280 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a vtable pointer
@@ -285,7 +285,7 @@ LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute
285285 }
286286
287287error[E0080]: it is undefined behavior to use this value
288- --> $DIR/ub-wide-ptr.rs:145 :1
288+ --> $DIR/ub-wide-ptr.rs:146 :1
289289 |
290290LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) };
291291 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC28<imm>, but expected a vtable pointer
@@ -296,7 +296,7 @@ LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transm
296296 }
297297
298298error[E0080]: it is undefined behavior to use this value
299- --> $DIR/ub-wide-ptr.rs:150 :1
299+ --> $DIR/ub-wide-ptr.rs:153 :1
300300 |
301301LL | static mut RAW_TRAIT_OBJ_VTABLE_NULL_THROUGH_REF: *const dyn Trait = unsafe {
302302 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a vtable pointer
@@ -307,7 +307,7 @@ LL | static mut RAW_TRAIT_OBJ_VTABLE_NULL_THROUGH_REF: *const dyn Trait = unsafe
307307 }
308308
309309error[E0080]: it is undefined behavior to use this value
310- --> $DIR/ub-wide-ptr.rs:154 :1
310+ --> $DIR/ub-wide-ptr.rs:157 :1
311311 |
312312LL | static mut RAW_TRAIT_OBJ_VTABLE_INVALID_THROUGH_REF: *const dyn Trait = unsafe {
313313 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC31<imm>, but expected a vtable pointer
0 commit comments