diff --git a/src/librustc/back/abi.rs b/src/librustc/back/abi.rs
index 8f639a5e499f1..83a17bd3231a2 100644
--- a/src/librustc/back/abi.rs
+++ b/src/librustc/back/abi.rs
@@ -42,11 +42,10 @@ pub static general_code_alignment: uint = 16u;
pub static tydesc_field_size: uint = 0u;
pub static tydesc_field_align: uint = 1u;
-pub static tydesc_field_take_glue: uint = 2u;
-pub static tydesc_field_drop_glue: uint = 3u;
-pub static tydesc_field_visit_glue: uint = 4u;
-pub static tydesc_field_name_offset: uint = 5u;
-pub static n_tydesc_fields: uint = 6u;
+pub static tydesc_field_drop_glue: uint = 2u;
+pub static tydesc_field_visit_glue: uint = 3u;
+pub static tydesc_field_name_offset: uint = 4u;
+pub static n_tydesc_fields: uint = 5u;
// The two halves of a closure: code and environment.
pub static fn_field_code: uint = 0u;
diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs
index c71469f0c3db0..1dea31939f57f 100644
--- a/src/librustc/middle/trans/base.rs
+++ b/src/librustc/middle/trans/base.rs
@@ -777,9 +777,6 @@ pub fn iter_structural_ty<'r,
let variant_cx =
fcx.new_temp_block(~"enum-iter-variant-" +
variant.disr_val.to_str());
- let variant_cx =
- iter_variant(variant_cx, repr, av, *variant,
- substs.tps, |x,y,z| f(x,y,z));
match adt::trans_case(cx, repr, variant.disr_val) {
_match::single_result(r) => {
AddCase(llswitch, r.val, variant_cx.llbb)
@@ -787,6 +784,9 @@ pub fn iter_structural_ty<'r,
_ => ccx.sess.unimpl("value from adt::trans_case \
in iter_structural_ty")
}
+ let variant_cx =
+ iter_variant(variant_cx, repr, av, *variant,
+ substs.tps, |x,y,z| f(x,y,z));
Br(variant_cx, next_cx.llbb);
}
cx = next_cx;
@@ -1458,16 +1458,16 @@ pub fn build_return_block(fcx: &FunctionContext, ret_cx: &Block) {
// trans_closure: Builds an LLVM function out of a source function.
// If the function closes over its environment a closure will be
// returned.
-pub fn trans_closure(ccx: @CrateContext,
- path: ast_map::Path,
- decl: &ast::FnDecl,
- body: &ast::Block,
- llfndecl: ValueRef,
- param_substs: Option<@param_substs>,
- id: ast::NodeId,
- _attributes: &[ast::Attribute],
- output_type: ty::t,
- maybe_load_env: |&FunctionContext|) {
+pub fn trans_closure<'a>(ccx: @CrateContext,
+ path: ast_map::Path,
+ decl: &ast::FnDecl,
+ body: &ast::Block,
+ llfndecl: ValueRef,
+ param_substs: Option<@param_substs>,
+ id: ast::NodeId,
+ _attributes: &[ast::Attribute],
+ output_type: ty::t,
+ maybe_load_env: |&'a Block<'a>| -> &'a Block<'a>) {
ccx.stats.n_closures.set(ccx.stats.n_closures.get() + 1);
let _icx = push_ctxt("trans_closure");
@@ -1500,7 +1500,7 @@ pub fn trans_closure(ccx: @CrateContext,
bcx = copy_args_to_allocas(&fcx, arg_scope, bcx, decl.inputs, arg_datums);
- maybe_load_env(&fcx);
+ bcx = maybe_load_env(bcx);
// Up until here, IR instructions for this function have explicitly not been annotated with
// source code location, so we don't step into call setup code. From here on, source location
@@ -1558,16 +1558,8 @@ pub fn trans_fn(ccx: @CrateContext,
debug!("trans_fn(param_substs={})", param_substs.repr(ccx.tcx));
let _icx = push_ctxt("trans_fn");
let output_type = ty::ty_fn_ret(ty::node_id_to_type(ccx.tcx, id));
- trans_closure(ccx,
- path.clone(),
- decl,
- body,
- llfndecl,
- param_substs,
- id,
- attrs,
- output_type,
- |_fcx| { });
+ trans_closure(ccx, path.clone(), decl, body, llfndecl,
+ param_substs, id, attrs, output_type, |bcx| bcx);
}
pub fn trans_enum_variant(ccx: @CrateContext,
diff --git a/src/librustc/middle/trans/closure.rs b/src/librustc/middle/trans/closure.rs
index 4d171bc86b1b0..5a8039f9c4d65 100644
--- a/src/librustc/middle/trans/closure.rs
+++ b/src/librustc/middle/trans/closure.rs
@@ -282,23 +282,22 @@ fn build_closure<'a>(bcx0: &'a Block<'a>,
// Given an enclosing block context, a new function context, a closure type,
// and a list of upvars, generate code to load and populate the environment
// with the upvars and type descriptors.
-fn load_environment(fcx: &FunctionContext, cdata_ty: ty::t,
- cap_vars: &[moves::CaptureVar], sigil: ast::Sigil) {
+fn load_environment<'a>(bcx: &'a Block<'a>, cdata_ty: ty::t,
+ cap_vars: &[moves::CaptureVar],
+ sigil: ast::Sigil) -> &'a Block<'a> {
let _icx = push_ctxt("closure::load_environment");
// Don't bother to create the block if there's nothing to load
if cap_vars.len() == 0 {
- return;
+ return bcx;
}
- let bcx = fcx.entry_bcx.get().unwrap();
-
// Load a pointer to the closure data, skipping over the box header:
- let llcdata = at_box_body(bcx, cdata_ty, fcx.llenv.unwrap());
+ let llcdata = at_box_body(bcx, cdata_ty, bcx.fcx.llenv.unwrap());
// Store the pointer to closure data in an alloca for debug info because that's what the
// llvm.dbg.declare intrinsic expects
- let env_pointer_alloca = if fcx.ccx.sess.opts.extra_debuginfo {
+ let env_pointer_alloca = if bcx.ccx().sess.opts.extra_debuginfo {
let alloc = alloc_ty(bcx, ty::mk_mut_ptr(bcx.tcx(), cdata_ty), "__debuginfo_env_ptr");
Store(bcx, llcdata, alloc);
Some(alloc)
@@ -317,7 +316,7 @@ fn load_environment(fcx: &FunctionContext, cdata_ty: ty::t,
let def_id = ast_util::def_id_of_def(cap_var.def);
{
- let mut llupvars = fcx.llupvars.borrow_mut();
+ let mut llupvars = bcx.fcx.llupvars.borrow_mut();
llupvars.get().insert(def_id.node, upvarptr);
}
@@ -334,6 +333,8 @@ fn load_environment(fcx: &FunctionContext, cdata_ty: ty::t,
i += 1u;
}
+
+ bcx
}
fn fill_fn_pair(bcx: &Block, pair: ValueRef, llfn: ValueRef, llenvptr: ValueRef) {
@@ -405,7 +406,7 @@ pub fn trans_expr_fn<'a>(
trans_closure(ccx, sub_path, decl, body, llfn,
bcx.fcx.param_substs, user_id,
[], ty::ty_fn_ret(fty),
- |fcx| load_environment(fcx, cdata_ty, cap_vars, sigil));
+ |bcx| load_environment(bcx, cdata_ty, cap_vars, sigil));
fill_fn_pair(bcx, dest_addr, llfn, llbox);
bcx
diff --git a/src/librustc/middle/trans/common.rs b/src/librustc/middle/trans/common.rs
index 45f5d84eb8ae4..38badc20c19ac 100644
--- a/src/librustc/middle/trans/common.rs
+++ b/src/librustc/middle/trans/common.rs
@@ -114,7 +114,6 @@ pub struct tydesc_info {
size: ValueRef,
align: ValueRef,
name: ValueRef,
- take_glue: Cell