From d94fe1d717dd3a6e1b9c0da1d4788dafb6695c9d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 20 Dec 2018 14:57:21 +0100 Subject: [PATCH] Fix calling drop_in_place_real with empty drop glue fixes #209 --- src/abi.rs | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index c9559a60689..d0706793081 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -484,11 +484,26 @@ pub fn codegen_terminator_call<'a, 'tcx: 'a>( .map(|&(ref place, bb)| (trans_place(fx, place), bb)); if let ty::FnDef(def_id, substs) = fn_ty.sty { - let sig = ty_fn_sig(fx.tcx, fn_ty); + let instance = ty::Instance::resolve( + fx.tcx, + ty::ParamEnv::reveal_all(), + def_id, + substs, + ).unwrap(); - if sig.abi == Abi::RustIntrinsic { - crate::intrinsics::codegen_intrinsic_call(fx, def_id, substs, args, destination); - return; + match instance.def { + InstanceDef::Intrinsic(_) => { + crate::intrinsics::codegen_intrinsic_call(fx, def_id, substs, args, destination); + return; + } + InstanceDef::DropGlue(_, None) => { + // empty drop glue - a nop. + let (_, dest) = destination.expect("Non terminating drop_in_place_real???"); + let ret_ebb = fx.get_ebb(dest); + fx.bcx.ins().jump(ret_ebb, &[]); + return; + } + _ => {} } }