Skip to content

Commit 389852b

Browse files
committed
Fix tags of unique boxes
Issue #409
1 parent 223f5be commit 389852b

File tree

5 files changed

+52
-3
lines changed

5 files changed

+52
-3
lines changed

src/comp/middle/trans.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5459,8 +5459,11 @@ fn trans_tag_variant(cx: @local_ctxt, tag_id: ast::node_id,
54595459
let arg_ty = arg_tys[i].ty;
54605460
let llargval;
54615461
if ty::type_is_structural(cx.ccx.tcx, arg_ty) ||
5462-
ty::type_has_dynamic_size(cx.ccx.tcx, arg_ty) ||
5463-
ty::type_is_unique(cx.ccx.tcx, arg_ty) {
5462+
ty::type_has_dynamic_size(cx.ccx.tcx, arg_ty) ||
5463+
(ty::type_is_unique(cx.ccx.tcx, arg_ty)
5464+
&& !ty::type_is_unique_box(cx.ccx.tcx, arg_ty)) {
5465+
// FIXME: Why do we do this for other unique pointer types but not
5466+
// unique boxes? Something's not quite right.
54645467
llargval = llargptr;
54655468
} else { llargval = Load(bcx, llargptr); }
54665469
bcx = copy_val(bcx, INIT, lldestptr, llargval, arg_ty);
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
fn main() {
2+
tag t { t1(int); t2(int); }
3+
4+
let x = ~t1(10);
5+
6+
alt *x {
7+
t1(a) {
8+
assert a == 10;
9+
}
10+
_ { fail; }
11+
}
12+
13+
alt x {
14+
~t1(a) {
15+
assert a == 10;
16+
}
17+
_ { fail; }
18+
}
19+
}

src/test/run-pass/unique-in-tag.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
fn test1() {
2+
tag bar { u(~int); w(int); }
3+
4+
let x = u(~10);
5+
assert alt x {
6+
u(a) {
7+
log_err a;
8+
*a
9+
}
10+
_ { 66 }
11+
} == 10;
12+
}
13+
14+
fn main() {
15+
test1();
16+
}

src/test/run-pass/unique-pat-2.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// xfail-test
21

32
type foo = {a: int, b: uint};
43
tag bar { u(~foo); w(int); }

src/test/run-pass/unique-pat-3.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
tag bar { u(~int); w(int); }
3+
4+
fn main() {
5+
assert alt u(~10) {
6+
u(a) {
7+
log_err a;
8+
*a
9+
}
10+
_ { 66 }
11+
} == 10;
12+
}

0 commit comments

Comments
 (0)