diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-12-13 20:35:31 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-12-13 20:35:31 +0100 |
| commit | a0be3a683d40981b5ea19c94640621f0816c3b1a (patch) | |
| tree | 3ec0c1f9e9973d75a3da42fdb2fef6ab930ed6ac | |
| parent | 48164f8a17501e7386afa4a371432168e598fcb5 (diff) | |
| parent | b2392aa2fcf0b4638b5db42fab12b1a4d2d98e28 (diff) | |
| download | rust-a0be3a683d40981b5ea19c94640621f0816c3b1a.tar.gz rust-a0be3a683d40981b5ea19c94640621f0816c3b1a.zip | |
Rollup merge of #67254 - RalfJung:vtable-ice, r=oli-obk
dont ICE in case of invalid drop fn Fixes https://github.com/rust-lang/miri/issues/1112 r? @oli-obk
| -rw-r--r-- | src/librustc_mir/interpret/traits.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/librustc_mir/interpret/traits.rs b/src/librustc_mir/interpret/traits.rs index efa0d266cbc..916ea3dc393 100644 --- a/src/librustc_mir/interpret/traits.rs +++ b/src/librustc_mir/interpret/traits.rs @@ -140,7 +140,18 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { let fn_sig = drop_instance.ty(*self.tcx).fn_sig(*self.tcx); let fn_sig = self.tcx.normalize_erasing_late_bound_regions(self.param_env, &fn_sig); // The drop function takes `*mut T` where `T` is the type being dropped, so get that. - let ty = fn_sig.inputs()[0].builtin_deref(true).unwrap().ty; + let args = fn_sig.inputs(); + if args.len() != 1 { + throw_ub_format!( + "drop fn should have 1 argument, but signature is {:?}", fn_sig + ); + } + let ty = args[0].builtin_deref(true) + .ok_or_else(|| err_ub_format!( + "drop fn argument type {} is not a pointer type", + args[0] + ))? + .ty; Ok((drop_instance, ty)) } |
