Skip to content

Commit 3f41563

Browse files
committed
Drop the previous value when copying one unique box local to another
Issue #409
1 parent 7c4fe10 commit 3f41563

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/comp/middle/trans.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2031,8 +2031,7 @@ fn copy_val_no_check(cx: @block_ctxt, action: copy_action, dst: ValueRef,
20312031
}
20322032
if ty::type_is_unique_box(ccx.tcx, t) {
20332033
let bcx = cx;
2034-
// FIXME (409): Write a test and uncomment
2035-
//if action == DROP_EXISTING { bcx = drop_ty(cx, dst, t); }
2034+
if action == DROP_EXISTING { bcx = drop_ty(cx, dst, t); }
20362035
check trans_uniq::type_is_unique_box(bcx, t);
20372036
ret trans_uniq::copy_val(bcx, dst, src, t);
20382037
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
fn main() {
2+
let i = ~1;
3+
let j = ~2;
4+
// Should drop the previous value of j
5+
j = i;
6+
assert *j == 1;
7+
}

0 commit comments

Comments
 (0)