]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_trans/trans/intrinsic.rs
rollup merge of #21830: japaric/for-cleanup
[rust.git] / src / librustc_trans / trans / intrinsic.rs
index 340fcb76058e255d97829935cbe94e4c0412f22a..6228043eeb1a9b307bf50dfa4e57f33ed0189e28 100644 (file)
@@ -243,7 +243,8 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
                     dest
                 };
 
-                fcx.pop_custom_cleanup_scope(cleanup_scope);
+                fcx.scopes.borrow_mut().last_mut().unwrap().drop_non_lifetime_clean();
+                fcx.pop_and_trans_custom_cleanup_scope(bcx, cleanup_scope);
 
                 return match dest {
                     expr::SaveIn(d) => Result::new(bcx, d),
@@ -268,7 +269,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
                              false,
                              RustIntrinsic);
 
-    fcx.pop_custom_cleanup_scope(cleanup_scope);
+    fcx.scopes.borrow_mut().last_mut().unwrap().drop_non_lifetime_clean();
 
     let call_debug_location = DebugLoc::At(call_info.id, call_info.span);
 
@@ -276,9 +277,11 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
     if name.get() == "abort" {
         let llfn = ccx.get_intrinsic(&("llvm.trap"));
         Call(bcx, llfn, &[], None, call_debug_location);
+        fcx.pop_and_trans_custom_cleanup_scope(bcx, cleanup_scope);
         Unreachable(bcx);
         return Result::new(bcx, C_undef(Type::nil(ccx).ptr_to()));
     } else if name.get() == "unreachable" {
+        fcx.pop_and_trans_custom_cleanup_scope(bcx, cleanup_scope);
         Unreachable(bcx);
         return Result::new(bcx, C_nil(ccx));
     }
@@ -765,6 +768,8 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
         expr::SaveIn(_) => {}
     }
 
+    fcx.pop_and_trans_custom_cleanup_scope(bcx, cleanup_scope);
+
     Result::new(bcx, llresult)
 }