don't ICE on invalid dyn calls

This commit is contained in:
Ralf Jung 2022-07-24 09:21:05 -04:00
parent b4151a41a0
commit f80bf1013d

View file

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