Skip to content

Commit 3a13330

Browse files
committed
---
yaml --- r: 5449 b: refs/heads/master c: 268a9fe h: refs/heads/master i: 5447: eb5e89f v: v3
1 parent c4dc30c commit 3a13330

File tree

5 files changed

+35
-7
lines changed

5 files changed

+35
-7
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 5d5136df9f9ead38745e35752abdb59d5ce4991f
2+
refs/heads/master: 268a9fe5fb3e6ac1f5bc3f1a7784da751cb56af8

trunk/src/comp/middle/trans.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2030,11 +2030,11 @@ fn copy_val_no_check(cx: @block_ctxt, action: copy_action, dst: ValueRef,
20302030
ret take_ty(bcx, dst, t);
20312031
}
20322032
if ty::type_is_unique_box(ccx.tcx, t) {
2033-
//let bcx = cx;
2033+
let bcx = cx;
20342034
// FIXME (409): Write a test and uncomment
20352035
//if action == DROP_EXISTING { bcx = drop_ty(cx, dst, t); }
2036-
//ret trans_uniq::copy_val(bcx, dst, src, t);
2037-
fail;
2036+
check trans_uniq::type_is_unique_box(bcx, t);
2037+
ret trans_uniq::copy_val(bcx, dst, src, t);
20382038
}
20392039
if type_is_structural_or_param(ccx.tcx, t) || ty::type_is_vec(ccx.tcx, t)
20402040
{

trunk/src/comp/middle/trans_uniq.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import trans::{
1515
new_sub_block_ctxt
1616
};
1717

18-
export trans_uniq, make_free_glue, type_is_unique_box;
18+
export trans_uniq, make_free_glue, type_is_unique_box, copy_val;
1919

2020
pure fn type_is_unique_box(bcx: @block_ctxt, ty: ty::t) -> bool {
2121
unchecked {
@@ -35,6 +35,8 @@ fn trans_uniq(cx: @block_ctxt, contents: @ast::expr,
3535
let content_ty = content_ty(bcx, uniq_ty);
3636
let {bcx, val: llptr} = alloc_uniq(bcx, uniq_ty);
3737

38+
add_clean_temp(bcx, llptr, uniq_ty);
39+
3840
bcx = move_val_if_temp(bcx, INIT, llptr, lv,
3941
content_ty);
4042

@@ -56,8 +58,6 @@ fn alloc_uniq(cx: @block_ctxt, uniq_ty: ty::t)
5658
bcx = r.bcx;
5759
let llptr = r.val;
5860

59-
add_clean_temp(bcx, llptr, uniq_ty);
60-
6161
ret rslt(bcx, llptr);
6262
}
6363

@@ -86,4 +86,18 @@ fn content_ty(bcx: @block_ctxt, t: ty::t)
8686
alt ty::struct(bcx_tcx(bcx), t) {
8787
ty::ty_uniq({ty: ct, _}) { ct }
8888
}
89+
}
90+
91+
fn copy_val(cx: @block_ctxt, dst: ValueRef, src: ValueRef,
92+
ty: ty::t) : type_is_unique_box(cx, ty) -> @block_ctxt {
93+
94+
let content_ty = content_ty(cx, ty);
95+
let {bcx, val: llptr} = alloc_uniq(cx, ty);
96+
Store(bcx, llptr, dst);
97+
98+
let src = Load(bcx, src);
99+
let dst = Load(bcx, dst);
100+
let bcx = trans::copy_val(bcx, INIT, dst, src, content_ty);
101+
Store(bcx, src, llptr);
102+
ret bcx;
89103
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
fn main() {
2+
let i = ~mutable 1;
3+
// Should be a copy
4+
let j = i;
5+
*i = 2;
6+
*j = 3;
7+
assert *i == 2;
8+
assert *j == 3;
9+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
fn main() {
2+
let i = ~1;
3+
let j = i;
4+
assert *j == 1;
5+
}

0 commit comments

Comments
 (0)