@@ -149,8 +149,19 @@ LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }];
149
149
╾─allocN─╼ │ ╾──╼
150
150
}
151
151
152
+ error: any use of this value will cause an error
153
+ --> $DIR/ub-wide-ptr.rs:87:40
154
+ |
155
+ LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }];
156
+ | ---------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
157
+ | |
158
+ | referenced constant has errors
159
+ |
160
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
161
+ = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
162
+
152
163
error[E0080]: it is undefined behavior to use this value
153
- --> $DIR/ub-wide-ptr.rs:93 :1
164
+ --> $DIR/ub-wide-ptr.rs:95 :1
154
165
|
155
166
LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]);
156
167
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .<deref>.0: encountered 0x03, but expected a boolean
@@ -160,8 +171,19 @@ LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3
160
171
╾allocN─╼ │ ╾──╼
161
172
}
162
173
174
+ error: any use of this value will cause an error
175
+ --> $DIR/ub-wide-ptr.rs:95:42
176
+ |
177
+ LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]);
178
+ | -----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
179
+ | |
180
+ | referenced constant has errors
181
+ |
182
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
183
+ = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
184
+
163
185
error[E0080]: it is undefined behavior to use this value
164
- --> $DIR/ub-wide-ptr.rs:96 :1
186
+ --> $DIR/ub-wide-ptr.rs:100 :1
165
187
|
166
188
LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]);
167
189
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .<deref>.1[0]: encountered 0x03, but expected a boolean
@@ -171,8 +193,19 @@ LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::tran
171
193
╾allocN─╼ │ ╾──╼
172
194
}
173
195
196
+ error: any use of this value will cause an error
197
+ --> $DIR/ub-wide-ptr.rs:100:42
198
+ |
199
+ LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]);
200
+ | -----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
201
+ | |
202
+ | referenced constant has errors
203
+ |
204
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
205
+ = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
206
+
174
207
error[E0080]: it is undefined behavior to use this value
175
- --> $DIR/ub-wide-ptr.rs:103 :1
208
+ --> $DIR/ub-wide-ptr.rs:109 :1
176
209
|
177
210
LL | / const RAW_SLICE_LENGTH_UNINIT: *const [u8] = unsafe {
178
211
LL | |
@@ -187,7 +220,7 @@ LL | | };
187
220
}
188
221
189
222
error[E0080]: it is undefined behavior to use this value
190
- --> $DIR/ub-wide-ptr.rs:111 :1
223
+ --> $DIR/ub-wide-ptr.rs:117 :1
191
224
|
192
225
LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) };
193
226
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .0: encountered too small vtable
@@ -198,7 +231,7 @@ LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((
198
231
}
199
232
200
233
error[E0080]: it is undefined behavior to use this value
201
- --> $DIR/ub-wide-ptr.rs:114 :1
234
+ --> $DIR/ub-wide-ptr.rs:120 :1
202
235
|
203
236
LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) };
204
237
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .0: encountered too small vtable
@@ -209,7 +242,7 @@ LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((
209
242
}
210
243
211
244
error[E0080]: it is undefined behavior to use this value
212
- --> $DIR/ub-wide-ptr.rs:117 :1
245
+ --> $DIR/ub-wide-ptr.rs:123 :1
213
246
|
214
247
LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, 4usize))) };
215
248
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .0: encountered dangling vtable pointer in wide pointer
@@ -220,7 +253,7 @@ LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u
220
253
}
221
254
222
255
error[E0080]: it is undefined behavior to use this value
223
- --> $DIR/ub-wide-ptr.rs:119 :1
256
+ --> $DIR/ub-wide-ptr.rs:125 :1
224
257
|
225
258
LL | const TRAIT_OBJ_UNALIGNED_VTABLE: &dyn Trait = unsafe { mem::transmute((&92u8, &[0u8; 128])) };
226
259
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered unaligned vtable pointer in wide pointer
@@ -231,7 +264,7 @@ LL | const TRAIT_OBJ_UNALIGNED_VTABLE: &dyn Trait = unsafe { mem::transmute((&92
231
264
}
232
265
233
266
error[E0080]: it is undefined behavior to use this value
234
- --> $DIR/ub-wide-ptr.rs:121 :1
267
+ --> $DIR/ub-wide-ptr.rs:127 :1
235
268
|
236
269
LL | const TRAIT_OBJ_BAD_DROP_FN_NULL: &dyn Trait = unsafe { mem::transmute((&92u8, &[0usize; 8])) };
237
270
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered invalid drop function pointer in vtable (not pointing to a function)
@@ -242,7 +275,7 @@ LL | const TRAIT_OBJ_BAD_DROP_FN_NULL: &dyn Trait = unsafe { mem::transmute((&92
242
275
}
243
276
244
277
error[E0080]: it is undefined behavior to use this value
245
- --> $DIR/ub-wide-ptr.rs:123 :1
278
+ --> $DIR/ub-wide-ptr.rs:129 :1
246
279
|
247
280
LL | const TRAIT_OBJ_BAD_DROP_FN_INT: &dyn Trait = unsafe { mem::transmute((&92u8, &[1usize; 8])) };
248
281
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered invalid drop function pointer in vtable (not pointing to a function)
@@ -253,7 +286,7 @@ LL | const TRAIT_OBJ_BAD_DROP_FN_INT: &dyn Trait = unsafe { mem::transmute((&92u
253
286
}
254
287
255
288
error[E0080]: it is undefined behavior to use this value
256
- --> $DIR/ub-wide-ptr.rs:125 :1
289
+ --> $DIR/ub-wide-ptr.rs:131 :1
257
290
|
258
291
LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &[&42u8; 8]))) };
259
292
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .0: encountered invalid drop function pointer in vtable (not pointing to a function)
@@ -264,7 +297,7 @@ LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::trans
264
297
}
265
298
266
299
error[E0080]: it is undefined behavior to use this value
267
- --> $DIR/ub-wide-ptr.rs:129 :1
300
+ --> $DIR/ub-wide-ptr.rs:135 :1
268
301
|
269
302
LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) };
270
303
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .<deref>.<dyn-downcast>: encountered 0x03, but expected a boolean
@@ -275,7 +308,7 @@ LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_,
275
308
}
276
309
277
310
error[E0080]: it is undefined behavior to use this value
278
- --> $DIR/ub-wide-ptr.rs:133 :1
311
+ --> $DIR/ub-wide-ptr.rs:139 :1
279
312
|
280
313
LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) };
281
314
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered dangling vtable pointer in wide pointer
@@ -286,7 +319,7 @@ LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute
286
319
}
287
320
288
321
error[E0080]: it is undefined behavior to use this value
289
- --> $DIR/ub-wide-ptr.rs:135 :1
322
+ --> $DIR/ub-wide-ptr.rs:141 :1
290
323
|
291
324
LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) };
292
325
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered too small vtable
@@ -297,17 +330,17 @@ LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transm
297
330
}
298
331
299
332
error[E0080]: could not evaluate static initializer
300
- --> $DIR/ub-wide-ptr.rs:141 :5
333
+ --> $DIR/ub-wide-ptr.rs:147 :5
301
334
|
302
335
LL | mem::transmute::<_, &dyn Trait>((&92u8, 0usize))
303
336
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: null pointer is not a valid pointer
304
337
305
338
error[E0080]: could not evaluate static initializer
306
- --> $DIR/ub-wide-ptr.rs:145 :5
339
+ --> $DIR/ub-wide-ptr.rs:151 :5
307
340
|
308
341
LL | mem::transmute::<_, &dyn Trait>((&92u8, &3u64))
309
342
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: allocN has size N, so pointer to 12 bytes starting at offset N is out-of-bounds
310
343
311
- error: aborting due to 29 previous errors
344
+ error: aborting due to 32 previous errors
312
345
313
346
For more information about this error, try `rustc --explain E0080`.
0 commit comments