Skip to content

Commit

Permalink
Rollup merge of rust-lang#99673 - RalfJung:interpret-invalid-dyn, r=o…
Browse files Browse the repository at this point in the history
…li-obk

don't ICE on invalid dyn calls

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

r? `@oli-obk`
  • Loading branch information
Dylan-DPC authored Jul 25, 2022
2 parents 5d015ae + f80bf10 commit f3bf936
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 f3bf936

Please sign in to comment.