Skip to content

Commit 9626e2f

Browse files
committed
Register tuple cleanups after the tuple is built
Issue #936
1 parent a18986c commit 9626e2f

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/comp/middle/trans.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -3939,7 +3939,6 @@ fn trans_tup(cx: @block_ctxt, elts: [@ast::expr], id: ast::node_id) ->
39393939
let tup_res = alloc_ty(bcx, t);
39403940
let tup_val = tup_res.val;
39413941
bcx = tup_res.bcx;
3942-
add_clean_temp(cx, tup_val, t);
39433942
let i: int = 0;
39443943
for e in elts {
39453944
let e_ty = ty::expr_ty(cx.fcx.lcx.ccx.tcx, e);
@@ -3951,6 +3950,9 @@ fn trans_tup(cx: @block_ctxt, elts: [@ast::expr], id: ast::node_id) ->
39513950
bcx = move_val_if_temp(dst_res.bcx, INIT, dst_res.val, src, e_ty);
39523951
i += 1;
39533952
}
3953+
3954+
// Only register the cleanups after the tuple is built
3955+
add_clean_temp(cx, tup_val, t);
39543956
ret rslt(bcx, tup_val);
39553957
}
39563958

src/test/run-fail/unwind-tup.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// error-pattern:fail
2+
3+
fn fold_local() -> @[int]{
4+
fail;
5+
}
6+
7+
fn main() {
8+
let lss = (fold_local(), 0);
9+
}

0 commit comments

Comments
 (0)