diff --git a/src/rustc/middle/trans/closure.rs b/src/rustc/middle/trans/closure.rs index 1ab25a1832932..655efe75bf65c 100644 --- a/src/rustc/middle/trans/closure.rs +++ b/src/rustc/middle/trans/closure.rs @@ -244,7 +244,6 @@ fn store_environment(bcx: block, fn build_closure(bcx0: block, cap_vars: ~[capture::capture_var], ck: ty::closure_kind, - id: ast::node_id, include_ret_handle: Option) -> closure_result { let _icx = bcx0.insn_ctxt("closure::build_closure"); // If we need to, package up the iterator body to call @@ -255,7 +254,7 @@ fn build_closure(bcx0: block, let mut env_vals = ~[]; for vec::each(cap_vars) |cap_var| { debug!("Building closure: captured variable %?", *cap_var); - let datum = expr::trans_local_var(bcx, id, cap_var.def); + let datum = expr::trans_local_var(bcx, cap_var.def); match cap_var.mode { capture::cap_ref => { assert ck == ty::ck_block; @@ -370,7 +369,7 @@ fn trans_expr_fn(bcx: block, let cap_vars = capture::compute_capture_vars(ccx.tcx, id, proto, cap_clause); let ret_handle = match is_loop_body { Some(x) => x, None => None }; - let {llbox, cdata_ty, bcx} = build_closure(bcx, cap_vars, ck, id, + let {llbox, cdata_ty, bcx} = build_closure(bcx, cap_vars, ck, ret_handle); trans_closure(ccx, sub_path, decl, body, llfn, no_self, bcx.fcx.param_substs, id, |fcx| { diff --git a/src/rustc/middle/trans/expr.rs b/src/rustc/middle/trans/expr.rs index c841d9bd91372..333d76a91ee68 100644 --- a/src/rustc/middle/trans/expr.rs +++ b/src/rustc/middle/trans/expr.rs @@ -748,13 +748,13 @@ fn trans_def_lvalue(bcx: block, ref_expr: @ast::expr, _ => { DatumBlock { bcx: bcx, - datum: trans_local_var(bcx, ref_expr.id, def) + datum: trans_local_var(bcx, def) } } } } -fn trans_local_var(bcx: block, ref_id: ast::node_id, def: ast::def) -> Datum { +fn trans_local_var(bcx: block, def: ast::def) -> Datum { let _icx = bcx.insn_ctxt("trans_local_var"); return match def { @@ -776,10 +776,10 @@ fn trans_local_var(bcx: block, ref_id: ast::node_id, def: ast::def) -> Datum { } } ast::def_arg(nid, _) => { - take_local(bcx, ref_id, bcx.fcx.llargs, nid) + take_local(bcx, bcx.fcx.llargs, nid) } ast::def_local(nid, _) | ast::def_binding(nid, _) => { - take_local(bcx, ref_id, bcx.fcx.lllocals, nid) + take_local(bcx, bcx.fcx.lllocals, nid) } ast::def_self(nid) => { let self_info: ValSelfData = match bcx.fcx.llself { @@ -809,15 +809,8 @@ fn trans_local_var(bcx: block, ref_id: ast::node_id, def: ast::def) -> Datum { }; fn take_local(bcx: block, - ref_id: ast::node_id, table: HashMap, nid: ast::node_id) -> Datum { - let is_last_use = match bcx.ccx().maps.last_use_map.find(ref_id) { - None => false, - Some(vars) => (*vars).contains(&nid) - }; - - let source = if is_last_use {FromLastUseLvalue} else {FromLvalue}; let (v, mode) = match table.find(nid) { Some(local_mem(v)) => (v, ByRef), @@ -829,10 +822,10 @@ fn trans_local_var(bcx: block, ref_id: ast::node_id, def: ast::def) -> Datum { }; let ty = node_id_type(bcx, nid); - debug!("take_local(nid=%?, last_use=%b, v=%s, mode=%?, ty=%s)", - nid, is_last_use, bcx.val_str(v), mode, bcx.ty_to_str(ty)); + debug!("take_local(nid=%?, v=%s, mode=%?, ty=%s)", + nid, bcx.val_str(v), mode, bcx.ty_to_str(ty)); - Datum { val: v, ty: ty, mode: mode, source: source } + Datum { val: v, ty: ty, mode: mode, source: FromLvalue } } }