]> git.lizzy.rs Git - rust.git/commitdiff
Fix calling drop_in_place_real with empty drop glue
authorbjorn3 <bjorn3@users.noreply.github.com>
Thu, 20 Dec 2018 13:57:21 +0000 (14:57 +0100)
committerbjorn3 <bjorn3@users.noreply.github.com>
Thu, 20 Dec 2018 13:57:34 +0000 (14:57 +0100)
fixes #209

src/abi.rs

index c9559a606891395112aa1a96b4fee8bb673e71e4..d07067930812d5739bccf1e8315e263f8b2ae84a 100644 (file)
@@ -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);
-
-        if sig.abi == Abi::RustIntrinsic {
-            crate::intrinsics::codegen_intrinsic_call(fx, def_id, substs, args, destination);
-            return;
+        let instance = ty::Instance::resolve(
+            fx.tcx,
+            ty::ParamEnv::reveal_all(),
+            def_id,
+            substs,
+        ).unwrap();
+
+        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;
+            }
+            _ => {}
         }
     }