Skip to content

Commit 9a233bb

Browse files
committed
interpret: make identity upcasts a NOP again to avoid them generating a new random vtable
1 parent dec5b46 commit 9a233bb

File tree

9 files changed

+158
-77
lines changed

9 files changed

+158
-77
lines changed

compiler/rustc_const_eval/src/interpret/cast.rs

+6
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,12 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
400400
}
401401
(ty::Dynamic(data_a, _, ty::Dyn), ty::Dynamic(data_b, _, ty::Dyn)) => {
402402
let val = self.read_immediate(src)?;
403+
// MIR building generates odd NOP casts, prevent them from causing unexpected trouble.
404+
// See <https://github.com/rust-lang/rust/issues/128880>.
405+
// FIXME: ideally we wouldn't have to do this.
406+
if data_a == data_b {
407+
return self.write_immediate(*val, dest);
408+
}
403409
// Take apart the old pointer, and find the dynamic type.
404410
let (old_data, old_vptr) = val.to_scalar_pair();
405411
let old_data = old_data.to_pointer(self)?;

tests/ui/consts/const-eval/raw-bytes.32bit.stderr

+16-6
Original file line numberDiff line numberDiff line change
@@ -436,17 +436,27 @@ LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_,
436436
╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──╼╾──╼
437437
}
438438

439-
error[E0080]: evaluation of constant value failed
440-
--> $DIR/raw-bytes.rs:196:62
439+
error[E0080]: it is undefined behavior to use this value
440+
--> $DIR/raw-bytes.rs:196:1
441441
|
442442
LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) };
443-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: expected a pointer to some allocation, but got a null pointer
443+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a vtable pointer
444+
|
445+
= 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.
446+
= note: the raw bytes of the constant (size: 8, align: 4) {
447+
╾ALLOC_ID╼ 00 00 00 00 │ ╾──╼....
448+
}
444449

445-
error[E0080]: evaluation of constant value failed
446-
--> $DIR/raw-bytes.rs:199:65
450+
error[E0080]: it is undefined behavior to use this value
451+
--> $DIR/raw-bytes.rs:199:1
447452
|
448453
LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) };
449-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using ALLOC32 as vtable pointer but it does not point to a vtable
454+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC27<imm>, but expected a vtable pointer
455+
|
456+
= 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.
457+
= note: the raw bytes of the constant (size: 8, align: 4) {
458+
╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──╼╾──╼
459+
}
450460

451461
error[E0080]: it is undefined behavior to use this value
452462
--> $DIR/raw-bytes.rs:204:1

tests/ui/consts/const-eval/raw-bytes.64bit.stderr

+16-6
Original file line numberDiff line numberDiff line change
@@ -436,17 +436,27 @@ LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_,
436436
╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──────╼╾──────╼
437437
}
438438

439-
error[E0080]: evaluation of constant value failed
440-
--> $DIR/raw-bytes.rs:196:62
439+
error[E0080]: it is undefined behavior to use this value
440+
--> $DIR/raw-bytes.rs:196:1
441441
|
442442
LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) };
443-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: expected a pointer to some allocation, but got a null pointer
443+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a vtable pointer
444+
|
445+
= 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.
446+
= note: the raw bytes of the constant (size: 16, align: 8) {
447+
╾ALLOC_ID╼ 00 00 00 00 00 00 00 00 │ ╾──────╼........
448+
}
444449

445-
error[E0080]: evaluation of constant value failed
446-
--> $DIR/raw-bytes.rs:199:65
450+
error[E0080]: it is undefined behavior to use this value
451+
--> $DIR/raw-bytes.rs:199:1
447452
|
448453
LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) };
449-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using ALLOC32 as vtable pointer but it does not point to a vtable
454+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC27<imm>, but expected a vtable pointer
455+
|
456+
= 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.
457+
= note: the raw bytes of the constant (size: 16, align: 8) {
458+
╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──────╼╾──────╼
459+
}
450460

451461
error[E0080]: it is undefined behavior to use this value
452462
--> $DIR/raw-bytes.rs:204:1

tests/ui/consts/const-eval/raw-bytes.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,10 @@ const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, &bool
194194
//~| expected a boolean
195195

196196
const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) };
197-
//~^ ERROR evaluation of constant value failed
197+
//~^ ERROR it is undefined behavior to use this value
198198
//~| null pointer
199199
const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) };
200-
//~^ ERROR evaluation of constant value failed
200+
//~^ ERROR it is undefined behavior to use this value
201201
//~| vtable
202202

203203
// Uninhabited types

tests/ui/consts/const-eval/ub-incorrect-vtable.32bit.stderr

+25-15
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,56 @@
1-
error[E0080]: evaluation of constant value failed
2-
--> $DIR/ub-incorrect-vtable.rs:19:14
1+
error[E0080]: it is undefined behavior to use this value
2+
--> $DIR/ub-incorrect-vtable.rs:18:1
3+
|
4+
LL | const INVALID_VTABLE_ALIGNMENT: &dyn Trait =
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC1<imm>, but expected a vtable pointer
36
|
4-
LL | unsafe { std::mem::transmute((&92u8, &[0usize, 1usize, 1000usize])) };
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using ALLOC8 as vtable pointer but it does not point to a vtable
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: 4) {
9+
╾ALLOC0<imm>╼ ╾ALLOC1<imm>╼ │ ╾──╼╾──╼
10+
}
611

7-
error[E0080]: evaluation of constant value failed
8-
--> $DIR/ub-incorrect-vtable.rs:24:14
12+
error[E0080]: it is undefined behavior to use this value
13+
--> $DIR/ub-incorrect-vtable.rs:23:1
14+
|
15+
LL | const INVALID_VTABLE_SIZE: &dyn Trait =
16+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC3<imm>, but expected a vtable pointer
917
|
10-
LL | unsafe { std::mem::transmute((&92u8, &[1usize, usize::MAX, 1usize])) };
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using ALLOC9 as vtable pointer but it does not point to a vtable
18+
= 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.
19+
= note: the raw bytes of the constant (size: 8, align: 4) {
20+
╾ALLOC2<imm>╼ ╾ALLOC3<imm>╼ │ ╾──╼╾──╼
21+
}
1222

1323
error[E0080]: it is undefined behavior to use this value
1424
--> $DIR/ub-incorrect-vtable.rs:33:1
1525
|
1626
LL | const INVALID_VTABLE_ALIGNMENT_UB: W<&dyn Trait> =
17-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC1<imm>, but expected a vtable pointer
27+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC5<imm>, but expected a vtable pointer
1828
|
1929
= 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.
2030
= note: the raw bytes of the constant (size: 8, align: 4) {
21-
ALLOC0<imm>╼ ╾ALLOC1<imm>╼ │ ╾──╼╾──╼
31+
ALLOC4<imm>╼ ╾ALLOC5<imm>╼ │ ╾──╼╾──╼
2232
}
2333

2434
error[E0080]: it is undefined behavior to use this value
2535
--> $DIR/ub-incorrect-vtable.rs:38:1
2636
|
2737
LL | const INVALID_VTABLE_SIZE_UB: W<&dyn Trait> =
28-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC3<imm>, but expected a vtable pointer
38+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC7<imm>, but expected a vtable pointer
2939
|
3040
= 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.
3141
= note: the raw bytes of the constant (size: 8, align: 4) {
32-
ALLOC2<imm>╼ ╾ALLOC3<imm>╼ │ ╾──╼╾──╼
42+
ALLOC6<imm>╼ ╾ALLOC7<imm>╼ │ ╾──╼╾──╼
3343
}
3444

3545
error[E0080]: it is undefined behavior to use this value
3646
--> $DIR/ub-incorrect-vtable.rs:44:1
3747
|
3848
LL | const INVALID_VTABLE_UB: W<&dyn Trait> =
39-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC5<imm>, but expected a vtable pointer
49+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC9<imm>, but expected a vtable pointer
4050
|
4151
= 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.
4252
= note: the raw bytes of the constant (size: 8, align: 4) {
43-
ALLOC4<imm>╼ ╾ALLOC5<imm>╼ │ ╾──╼╾──╼
53+
ALLOC8<imm>╼ ╾ALLOC9<imm>╼ │ ╾──╼╾──╼
4454
}
4555

4656
error[E0080]: it is undefined behavior to use this value
@@ -51,7 +61,7 @@ LL | const G: Wide = unsafe { Transmute { t: FOO }.u };
5161
|
5262
= 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.
5363
= note: the raw bytes of the constant (size: 8, align: 4) {
54-
ALLOC6<imm>╼ ╾ALLOC7╼ │ ╾──╼╾──╼
64+
ALLOC10<imm>╼ ╾ALLOC11╼ │ ╾──╼╾──╼
5565
}
5666

5767
error: aborting due to 6 previous errors

tests/ui/consts/const-eval/ub-incorrect-vtable.64bit.stderr

+25-15
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,56 @@
1-
error[E0080]: evaluation of constant value failed
2-
--> $DIR/ub-incorrect-vtable.rs:19:14
1+
error[E0080]: it is undefined behavior to use this value
2+
--> $DIR/ub-incorrect-vtable.rs:18:1
3+
|
4+
LL | const INVALID_VTABLE_ALIGNMENT: &dyn Trait =
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC1<imm>, but expected a vtable pointer
36
|
4-
LL | unsafe { std::mem::transmute((&92u8, &[0usize, 1usize, 1000usize])) };
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using ALLOC8 as vtable pointer but it does not point to a vtable
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: 16, align: 8) {
9+
╾ALLOC0<imm>╼ ╾ALLOC1<imm>╼ │ ╾──────╼╾──────╼
10+
}
611

7-
error[E0080]: evaluation of constant value failed
8-
--> $DIR/ub-incorrect-vtable.rs:24:14
12+
error[E0080]: it is undefined behavior to use this value
13+
--> $DIR/ub-incorrect-vtable.rs:23:1
14+
|
15+
LL | const INVALID_VTABLE_SIZE: &dyn Trait =
16+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC3<imm>, but expected a vtable pointer
917
|
10-
LL | unsafe { std::mem::transmute((&92u8, &[1usize, usize::MAX, 1usize])) };
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using ALLOC9 as vtable pointer but it does not point to a vtable
18+
= 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.
19+
= note: the raw bytes of the constant (size: 16, align: 8) {
20+
╾ALLOC2<imm>╼ ╾ALLOC3<imm>╼ │ ╾──────╼╾──────╼
21+
}
1222

1323
error[E0080]: it is undefined behavior to use this value
1424
--> $DIR/ub-incorrect-vtable.rs:33:1
1525
|
1626
LL | const INVALID_VTABLE_ALIGNMENT_UB: W<&dyn Trait> =
17-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC1<imm>, but expected a vtable pointer
27+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC5<imm>, but expected a vtable pointer
1828
|
1929
= 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.
2030
= note: the raw bytes of the constant (size: 16, align: 8) {
21-
ALLOC0<imm>╼ ╾ALLOC1<imm>╼ │ ╾──────╼╾──────╼
31+
ALLOC4<imm>╼ ╾ALLOC5<imm>╼ │ ╾──────╼╾──────╼
2232
}
2333

2434
error[E0080]: it is undefined behavior to use this value
2535
--> $DIR/ub-incorrect-vtable.rs:38:1
2636
|
2737
LL | const INVALID_VTABLE_SIZE_UB: W<&dyn Trait> =
28-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC3<imm>, but expected a vtable pointer
38+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC7<imm>, but expected a vtable pointer
2939
|
3040
= 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.
3141
= note: the raw bytes of the constant (size: 16, align: 8) {
32-
ALLOC2<imm>╼ ╾ALLOC3<imm>╼ │ ╾──────╼╾──────╼
42+
ALLOC6<imm>╼ ╾ALLOC7<imm>╼ │ ╾──────╼╾──────╼
3343
}
3444

3545
error[E0080]: it is undefined behavior to use this value
3646
--> $DIR/ub-incorrect-vtable.rs:44:1
3747
|
3848
LL | const INVALID_VTABLE_UB: W<&dyn Trait> =
39-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC5<imm>, but expected a vtable pointer
49+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC9<imm>, but expected a vtable pointer
4050
|
4151
= 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.
4252
= note: the raw bytes of the constant (size: 16, align: 8) {
43-
ALLOC4<imm>╼ ╾ALLOC5<imm>╼ │ ╾──────╼╾──────╼
53+
ALLOC8<imm>╼ ╾ALLOC9<imm>╼ │ ╾──────╼╾──────╼
4454
}
4555

4656
error[E0080]: it is undefined behavior to use this value
@@ -51,7 +61,7 @@ LL | const G: Wide = unsafe { Transmute { t: FOO }.u };
5161
|
5262
= 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.
5363
= note: the raw bytes of the constant (size: 16, align: 8) {
54-
ALLOC6<imm>╼ ╾ALLOC7╼ │ ╾──────╼╾──────╼
64+
ALLOC10<imm>╼ ╾ALLOC11╼ │ ╾──────╼╾──────╼
5565
}
5666

5767
error: aborting due to 6 previous errors

tests/ui/consts/const-eval/ub-incorrect-vtable.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ trait Trait {}
1717

1818
const INVALID_VTABLE_ALIGNMENT: &dyn Trait =
1919
unsafe { std::mem::transmute((&92u8, &[0usize, 1usize, 1000usize])) };
20-
//~^ ERROR evaluation of constant value failed
20+
//~^^ ERROR it is undefined behavior to use this value
2121
//~| vtable
2222

2323
const INVALID_VTABLE_SIZE: &dyn Trait =
2424
unsafe { std::mem::transmute((&92u8, &[1usize, usize::MAX, 1usize])) };
25-
//~^ ERROR evaluation of constant value failed
25+
//~^^ ERROR it is undefined behavior to use this value
2626
//~| vtable
2727

2828
#[repr(transparent)]

tests/ui/consts/const-eval/ub-wide-ptr.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,13 @@ const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, 4u
123123
//~^ ERROR it is undefined behavior to use this value
124124
//~| vtable
125125
const TRAIT_OBJ_UNALIGNED_VTABLE: &dyn Trait = unsafe { mem::transmute((&92u8, &[0u8; 128])) };
126-
//~^ ERROR evaluation of constant value failed
126+
//~^ ERROR it is undefined behavior to use this value
127127
//~| vtable
128128
const TRAIT_OBJ_BAD_DROP_FN_NULL: &dyn Trait = unsafe { mem::transmute((&92u8, &[0usize; 8])) };
129-
//~^ ERROR evaluation of constant value failed
129+
//~^ ERROR it is undefined behavior to use this value
130130
//~| vtable
131131
const TRAIT_OBJ_BAD_DROP_FN_INT: &dyn Trait = unsafe { mem::transmute((&92u8, &[1usize; 8])) };
132-
//~^ ERROR evaluation of constant value failed
132+
//~^ ERROR it is undefined behavior to use this value
133133
//~| vtable
134134
const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &[&42u8; 8]))) };
135135
//~^ ERROR it is undefined behavior to use this value
@@ -142,10 +142,10 @@ const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, &bool
142142

143143
// # raw trait object
144144
const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) };
145-
//~^ ERROR evaluation of constant value failed
145+
//~^ ERROR it is undefined behavior to use this value
146146
//~| null pointer
147147
const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) };
148-
//~^ ERROR evaluation of constant value failed
148+
//~^ ERROR it is undefined behavior to use this value
149149
//~| vtable
150150
const RAW_TRAIT_OBJ_CONTENT_INVALID: *const dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) } as *const dyn Trait; // ok because raw
151151
// Officially blessed way to get the vtable
@@ -154,12 +154,12 @@ const DYN_METADATA: ptr::DynMetadata<dyn Send> = ptr::metadata::<dyn Send>(ptr::
154154

155155
static mut RAW_TRAIT_OBJ_VTABLE_NULL_THROUGH_REF: *const dyn Trait = unsafe {
156156
mem::transmute::<_, &dyn Trait>((&92u8, 0usize))
157-
//~^ ERROR could not evaluate static initializer
157+
//~^^ ERROR it is undefined behavior to use this value
158158
//~| null pointer
159159
};
160160
static mut RAW_TRAIT_OBJ_VTABLE_INVALID_THROUGH_REF: *const dyn Trait = unsafe {
161161
mem::transmute::<_, &dyn Trait>((&92u8, &3u64))
162-
//~^ ERROR could not evaluate static initializer
162+
//~^^ ERROR it is undefined behavior to use this value
163163
//~| vtable
164164
};
165165

0 commit comments

Comments
 (0)