mirror of
https://github.com/rust-lang/rust
synced 2024-09-05 16:57:03 +00:00
parent
223f5be166
commit
389852b5c0
|
@ -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);
|
||||
|
|
19
src/test/run-pass/unique-containing-tag.rs
Normal file
19
src/test/run-pass/unique-containing-tag.rs
Normal 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; }
|
||||
}
|
||||
}
|
16
src/test/run-pass/unique-in-tag.rs
Normal file
16
src/test/run-pass/unique-in-tag.rs
Normal 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();
|
||||
}
|
|
@ -1,4 +1,3 @@
|
|||
// xfail-test
|
||||
|
||||
type foo = {a: int, b: uint};
|
||||
tag bar { u(~foo); w(int); }
|
||||
|
|
12
src/test/run-pass/unique-pat-3.rs
Normal file
12
src/test/run-pass/unique-pat-3.rs
Normal 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;
|
||||
}
|
Loading…
Reference in a new issue