Skip to content

Commit 2973b00

Browse files
authored
Rollup merge of #99673 - RalfJung:interpret-invalid-dyn, r=oli-obk
don't ICE on invalid dyn calls Due to #50781 this is actually reachable. Fixes rust-lang/miri#2432 r? ``@oli-obk``
2 parents 74be487 + f80bf10 commit 2973b00

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

compiler/rustc_const_eval/src/interpret/terminator.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -571,8 +571,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
571571

572572
// Now determine the actual method to call. We can do that in two different ways and
573573
// compare them to ensure everything fits.
574-
let ty::VtblEntry::Method(fn_inst) = self.get_vtable_entries(vptr)?[idx] else {
575-
span_bug!(self.cur_span(), "dyn call index points at something that is not a method")
574+
let Some(ty::VtblEntry::Method(fn_inst)) = self.get_vtable_entries(vptr)?.get(idx).copied() else {
575+
throw_ub_format!("`dyn` call trying to call something that is not a method")
576576
};
577577
if cfg!(debug_assertions) {
578578
let tcx = *self.tcx;

0 commit comments

Comments
 (0)