Skip to content

Commit 03999ce

Browse files
committed
Interning even happens when validation of a constant fails
1 parent 5ee4865 commit 03999ce

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/librustc_mir/interpret/intern.rs

+12-6
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,18 @@ for
207207
self.ecx.tcx.struct_tail_erasing_lifetimes(
208208
referenced_ty, self.ecx.param_env).kind
209209
{
210-
// Validation has already errored on an invalid vtable pointer so this `assert_ptr`
211-
// will never panic.
212-
let vtable = mplace.meta.unwrap().assert_ptr();
213-
// explitly choose `Immutable` here, since vtables are immutable, even
214-
// if the reference of the fat pointer is mutable
215-
self.intern_shallow(vtable.alloc_id, Mutability::Immutable, None)?;
210+
// Validation has already errored on an invalid vtable pointer so we can safely not
211+
// do anything if this is not a real pointer
212+
if let Scalar::Ptr(vtable) = mplace.meta.unwrap() {
213+
// explitly choose `Immutable` here, since vtables are immutable, even
214+
// if the reference of the fat pointer is mutable
215+
self.intern_shallow(vtable.alloc_id, Mutability::Immutable, None)?;
216+
} else {
217+
self.ecx().tcx.sess.delay_span_bug(
218+
syntax_pos::DUMMY_SP,
219+
"vtables pointers cannot be integer pointers",
220+
);
221+
}
216222
}
217223
// Check if we have encountered this pointer+layout combination before.
218224
// Only recurse for allocation-backed pointers.

0 commit comments

Comments
 (0)