Drop the previous value when copying one unique box local to another
Issue #409
This commit is contained in:
parent
7c4fe10f02
commit
3f41563cc9
2 changed files with 8 additions and 2 deletions
|
|
@ -2031,8 +2031,7 @@ fn copy_val_no_check(cx: @block_ctxt, action: copy_action, dst: ValueRef,
|
|||
}
|
||||
if ty::type_is_unique_box(ccx.tcx, t) {
|
||||
let bcx = cx;
|
||||
// FIXME (409): Write a test and uncomment
|
||||
//if action == DROP_EXISTING { bcx = drop_ty(cx, dst, t); }
|
||||
if action == DROP_EXISTING { bcx = drop_ty(cx, dst, t); }
|
||||
check trans_uniq::type_is_unique_box(bcx, t);
|
||||
ret trans_uniq::copy_val(bcx, dst, src, t);
|
||||
}
|
||||
|
|
|
|||
7
src/test/run-pass/unique-assign-drop.rs
Normal file
7
src/test/run-pass/unique-assign-drop.rs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
fn main() {
|
||||
let i = ~1;
|
||||
let j = ~2;
|
||||
// Should drop the previous value of j
|
||||
j = i;
|
||||
assert *j == 1;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue