]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_trans/trans/expr.rs
rollup merge of #21438: taralx/kill-racycell
[rust.git] / src / librustc_trans / trans / expr.rs
index 7abd59ca0cd0e27fa6f09597398742db147ff8e7..da900f0a59eeb5af8fbbfac25d1dbd9dc5fee750 100644 (file)
@@ -65,7 +65,6 @@
 use trans::type_::Type;
 
 use syntax::{ast, ast_util, codemap};
-use syntax::print::pprust::{expr_to_string};
 use syntax::ptr::P;
 use syntax::parse::token;
 use std::rc::Rc;
@@ -1102,17 +1101,7 @@ fn make_field(field_name: &str, expr: P<ast::Expr>) -> ast::Field {
             // closure or an older, legacy style closure. Store this
             // into a variable to ensure the the RefCell-lock is
             // released before we recurse.
-            let is_unboxed_closure =
-                bcx.tcx().unboxed_closures.borrow().contains_key(&ast_util::local_def(expr.id));
-            if is_unboxed_closure {
-                closure::trans_unboxed_closure(bcx, &**decl, &**body, expr.id, dest)
-            } else {
-                let expr_ty = expr_ty(bcx, expr);
-                let store = ty::ty_closure_store(expr_ty);
-                debug!("translating block function {} with type {}",
-                       expr_to_string(expr), expr_ty.repr(tcx));
-                closure::trans_expr_fn(bcx, store, &**decl, &**body, expr.id, dest)
-            }
+            closure::trans_unboxed_closure(bcx, &**decl, &**body, expr.id, dest)
         }
         ast::ExprCall(ref f, ref args) => {
             if bcx.tcx().is_method_call(expr.id) {
@@ -1905,18 +1894,16 @@ fn int_cast(bcx: Block,
             signed: bool)
             -> ValueRef {
     let _icx = push_ctxt("int_cast");
-    unsafe {
-        let srcsz = llvm::LLVMGetIntTypeWidth(llsrctype.to_ref());
-        let dstsz = llvm::LLVMGetIntTypeWidth(lldsttype.to_ref());
-        return if dstsz == srcsz {
-            BitCast(bcx, llsrc, lldsttype)
-        } else if srcsz > dstsz {
-            TruncOrBitCast(bcx, llsrc, lldsttype)
-        } else if signed {
-            SExtOrBitCast(bcx, llsrc, lldsttype)
-        } else {
-            ZExtOrBitCast(bcx, llsrc, lldsttype)
-        };
+    let srcsz = llsrctype.int_width();
+    let dstsz = lldsttype.int_width();
+    return if dstsz == srcsz {
+        BitCast(bcx, llsrc, lldsttype)
+    } else if srcsz > dstsz {
+        TruncOrBitCast(bcx, llsrc, lldsttype)
+    } else if signed {
+        SExtOrBitCast(bcx, llsrc, lldsttype)
+    } else {
+        ZExtOrBitCast(bcx, llsrc, lldsttype)
     }
 }