Skip to content

Commit

Permalink
Rollup merge of #99673 - RalfJung:interpret-invalid-dyn, r=oli-obk
Browse files Browse the repository at this point in the history
don't ICE on invalid dyn calls

Due to #50781 this is actually reachable.
Fixes rust-lang/miri#2432

r? ``@oli-obk``
  • Loading branch information
JohnTitor committed Jul 25, 2022
2 parents 74be487 + f80bf10 commit 2973b00
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_const_eval/src/interpret/terminator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -571,8 +571,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {

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

0 comments on commit 2973b00

Please sign in to comment.