]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc/middle/trans/closure.rs
auto merge of #7903 : michaelwoerister/rust/end_of_spanned, r=jdm
[rust.git] / src / librustc / middle / trans / closure.rs
index fc5aacffc1aba0abdbd95e05500e53be1969549d..5723e24e421b8cb61975a4bfd4c127003366619c 100644 (file)
@@ -11,7 +11,7 @@
 
 use back::abi;
 use back::link::{mangle_internal_name_by_path_and_seq};
-use lib::llvm::{llvm, ValueRef};
+use lib::llvm::ValueRef;
 use middle::moves;
 use middle::trans::base::*;
 use middle::trans::build::*;
@@ -25,7 +25,6 @@
 
 use middle::trans::type_::Type;
 
-use std::str;
 use std::vec;
 use syntax::ast;
 use syntax::ast_map::path_name;
@@ -326,23 +325,12 @@ pub fn load_environment(fcx: fn_ctxt,
                         sigil: ast::Sigil) {
     let _icx = push_ctxt("closure::load_environment");
 
-    let llloadenv = match fcx.llloadenv {
-        Some(ll) => ll,
-        None => {
-            let ll =
-                str::as_c_str("load_env",
-                              |buf|
-                              unsafe {
-                                llvm::LLVMAppendBasicBlockInContext(fcx.ccx.llcx,
-                                                                    fcx.llfn,
-                                                                    buf)
-                              });
-            fcx.llloadenv = Some(ll);
-            ll
-        }
-    };
+    // Don't bother to create the block if there's nothing to load
+    if cap_vars.len() == 0 && !load_ret_handle {
+        return;
+    }
 
-    let bcx = raw_block(fcx, false, llloadenv);
+    let bcx = fcx.entry_bcx.get();
 
     // Load a pointer to the closure data, skipping over the box header:
     let llcdata = opaque_box_body(bcx, cdata_ty, fcx.llenv);