Skip to content

Commit c6780fb

Browse files
committed
Make trans ignore last use
1 parent c4155f5 commit c6780fb

File tree

2 files changed

+9
-17
lines changed

2 files changed

+9
-17
lines changed

src/rustc/middle/trans/closure.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,6 @@ fn store_environment(bcx: block,
244244
fn build_closure(bcx0: block,
245245
cap_vars: ~[capture::capture_var],
246246
ck: ty::closure_kind,
247-
id: ast::node_id,
248247
include_ret_handle: Option<ValueRef>) -> closure_result {
249248
let _icx = bcx0.insn_ctxt("closure::build_closure");
250249
// If we need to, package up the iterator body to call
@@ -255,7 +254,7 @@ fn build_closure(bcx0: block,
255254
let mut env_vals = ~[];
256255
for vec::each(cap_vars) |cap_var| {
257256
debug!("Building closure: captured variable %?", *cap_var);
258-
let datum = expr::trans_local_var(bcx, id, cap_var.def);
257+
let datum = expr::trans_local_var(bcx, cap_var.def);
259258
match cap_var.mode {
260259
capture::cap_ref => {
261260
assert ck == ty::ck_block;
@@ -370,7 +369,7 @@ fn trans_expr_fn(bcx: block,
370369
let cap_vars = capture::compute_capture_vars(ccx.tcx, id, proto,
371370
cap_clause);
372371
let ret_handle = match is_loop_body { Some(x) => x, None => None };
373-
let {llbox, cdata_ty, bcx} = build_closure(bcx, cap_vars, ck, id,
372+
let {llbox, cdata_ty, bcx} = build_closure(bcx, cap_vars, ck,
374373
ret_handle);
375374
trans_closure(ccx, sub_path, decl, body, llfn, no_self,
376375
bcx.fcx.param_substs, id, |fcx| {

src/rustc/middle/trans/expr.rs

+7-14
Original file line numberDiff line numberDiff line change
@@ -748,13 +748,13 @@ fn trans_def_lvalue(bcx: block, ref_expr: @ast::expr,
748748
_ => {
749749
DatumBlock {
750750
bcx: bcx,
751-
datum: trans_local_var(bcx, ref_expr.id, def)
751+
datum: trans_local_var(bcx, def)
752752
}
753753
}
754754
}
755755
}
756756

757-
fn trans_local_var(bcx: block, ref_id: ast::node_id, def: ast::def) -> Datum {
757+
fn trans_local_var(bcx: block, def: ast::def) -> Datum {
758758
let _icx = bcx.insn_ctxt("trans_local_var");
759759

760760
return match def {
@@ -776,10 +776,10 @@ fn trans_local_var(bcx: block, ref_id: ast::node_id, def: ast::def) -> Datum {
776776
}
777777
}
778778
ast::def_arg(nid, _) => {
779-
take_local(bcx, ref_id, bcx.fcx.llargs, nid)
779+
take_local(bcx, bcx.fcx.llargs, nid)
780780
}
781781
ast::def_local(nid, _) | ast::def_binding(nid, _) => {
782-
take_local(bcx, ref_id, bcx.fcx.lllocals, nid)
782+
take_local(bcx, bcx.fcx.lllocals, nid)
783783
}
784784
ast::def_self(nid) => {
785785
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 {
809809
};
810810

811811
fn take_local(bcx: block,
812-
ref_id: ast::node_id,
813812
table: HashMap<ast::node_id, local_val>,
814813
nid: ast::node_id) -> Datum {
815-
let is_last_use = match bcx.ccx().maps.last_use_map.find(ref_id) {
816-
None => false,
817-
Some(vars) => (*vars).contains(&nid)
818-
};
819-
820-
let source = if is_last_use {FromLastUseLvalue} else {FromLvalue};
821814

822815
let (v, mode) = match table.find(nid) {
823816
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 {
829822
};
830823
let ty = node_id_type(bcx, nid);
831824

832-
debug!("take_local(nid=%?, last_use=%b, v=%s, mode=%?, ty=%s)",
833-
nid, is_last_use, bcx.val_str(v), mode, bcx.ty_to_str(ty));
825+
debug!("take_local(nid=%?, v=%s, mode=%?, ty=%s)",
826+
nid, bcx.val_str(v), mode, bcx.ty_to_str(ty));
834827

835-
Datum { val: v, ty: ty, mode: mode, source: source }
828+
Datum { val: v, ty: ty, mode: mode, source: FromLvalue }
836829
}
837830
}
838831

0 commit comments

Comments
 (0)