about summary refs log tree commit diff
diff options
context:
space:
mode:
authorYuki Okushi <jtitor@2k36.org>2022-07-26 07:14:49 +0900
committerGitHub <noreply@github.com>2022-07-26 07:14:49 +0900
commit2973b00ca6bc85ba3552282657de81d4baf864cc (patch)
tree0b9b3bfb623d03cefd8f28f7984a75f0c8196a43
parent74be487ca093e67bc840a83414a916d91b825081 (diff)
parentf80bf1013d52c50e308746a977ed6a7cdd28c6a5 (diff)
downloadrust-2973b00ca6bc85ba3552282657de81d4baf864cc.tar.gz
rust-2973b00ca6bc85ba3552282657de81d4baf864cc.zip
Rollup merge of #99673 - RalfJung:interpret-invalid-dyn, r=oli-obk
don't ICE on invalid dyn calls

Due to https://github.com/rust-lang/rust/issues/50781 this is actually reachable.
Fixes https://github.com/rust-lang/miri/issues/2432

r? ``@oli-obk``
-rw-r--r--compiler/rustc_const_eval/src/interpret/terminator.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/terminator.rs b/compiler/rustc_const_eval/src/interpret/terminator.rs
index 42de0dbdca9..d563e35f910 100644
--- a/compiler/rustc_const_eval/src/interpret/terminator.rs
+++ b/compiler/rustc_const_eval/src/interpret/terminator.rs
@@ -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;