Fix tags of unique boxes

Issue #409
This commit is contained in:
Brian Anderson 2011-09-26 14:44:08 -07:00
parent 223f5be166
commit 389852b5c0
5 changed files with 52 additions and 3 deletions

View File

@ -5459,8 +5459,11 @@ fn trans_tag_variant(cx: @local_ctxt, tag_id: ast::node_id,
let arg_ty = arg_tys[i].ty;
let llargval;
if ty::type_is_structural(cx.ccx.tcx, arg_ty) ||
ty::type_has_dynamic_size(cx.ccx.tcx, arg_ty) ||
ty::type_is_unique(cx.ccx.tcx, arg_ty) {
ty::type_has_dynamic_size(cx.ccx.tcx, arg_ty) ||
(ty::type_is_unique(cx.ccx.tcx, arg_ty)
&& !ty::type_is_unique_box(cx.ccx.tcx, arg_ty)) {
// FIXME: Why do we do this for other unique pointer types but not
// unique boxes? Something's not quite right.
llargval = llargptr;
} else { llargval = Load(bcx, llargptr); }
bcx = copy_val(bcx, INIT, lldestptr, llargval, arg_ty);

View File

@ -0,0 +1,19 @@
fn main() {
tag t { t1(int); t2(int); }
let x = ~t1(10);
alt *x {
t1(a) {
assert a == 10;
}
_ { fail; }
}
alt x {
~t1(a) {
assert a == 10;
}
_ { fail; }
}
}

View File

@ -0,0 +1,16 @@
fn test1() {
tag bar { u(~int); w(int); }
let x = u(~10);
assert alt x {
u(a) {
log_err a;
*a
}
_ { 66 }
} == 10;
}
fn main() {
test1();
}

View File

@ -1,4 +1,3 @@
// xfail-test
type foo = {a: int, b: uint};
tag bar { u(~foo); w(int); }

View File

@ -0,0 +1,12 @@
tag bar { u(~int); w(int); }
fn main() {
assert alt u(~10) {
u(a) {
log_err a;
*a
}
_ { 66 }
} == 10;
}