Skip to content

Commit 94b681a

Browse files
committed
rustc: Use copy_ty() when initializing N-ary tag variants. Un-XFAIL generic-tag.rs.
1 parent 1dc6bdf commit 94b681a

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

src/Makefile

+1-2
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,7 @@ TEST_XFAILS_BOOT := $(TASK_XFAILS) \
432432
test/compile-fail/tail-non-call.rs \
433433
test/compile-fail/writing-through-read-alias.rs
434434

435-
TEST_XFAILS_RUSTC := $(CONST_TAG_XFAILS) \
436-
$(addprefix test/run-pass/, \
435+
TEST_XFAILS_RUSTC := $(addprefix test/run-pass/, \
437436
acyclic-unwind.rs \
438437
alt-pattern-drop.rs \
439438
alt-type-simple.rs \

src/comp/middle/trans.rs

+18-5
Original file line numberDiff line numberDiff line change
@@ -363,17 +363,22 @@ fn T_taskptr(type_names tn) -> TypeRef {
363363
ret T_ptr(T_task(tn));
364364
}
365365

366-
fn T_typaram_ptr(type_names tn) -> TypeRef {
366+
// This type must never be used directly; it must always be cast away.
367+
fn T_typaram(type_names tn) -> TypeRef {
367368
auto s = "typaram";
368369
if (tn.name_has_type(s)) {
369370
ret tn.get_type(s);
370371
}
371372

372-
auto t = T_ptr(T_i8());
373+
auto t = T_i8();
373374
tn.associate(s, t);
374375
ret t;
375376
}
376377

378+
fn T_typaram_ptr(type_names tn) -> TypeRef {
379+
ret T_ptr(T_typaram(tn));
380+
}
381+
377382
fn T_closure_ptr(type_names tn,
378383
TypeRef lltarget_ty,
379384
TypeRef llbindings_ty,
@@ -2068,7 +2073,6 @@ fn call_tydesc_glue(@block_ctxt cx, ValueRef v, @ty.t t, int field) {
20682073
fn incr_all_refcnts(@block_ctxt cx,
20692074
ValueRef v,
20702075
@ty.t t) -> result {
2071-
20722076
if (!ty.type_is_scalar(t)) {
20732077
call_tydesc_glue(cx, v, t, abi.tydesc_field_take_glue_off);
20742078
}
@@ -4820,9 +4824,18 @@ fn trans_tag_variant(@crate_ctxt cx, ast.def_id tag_id,
48204824
// works. So we have to cast to the destination's view of the type.
48214825
auto llargptr = bcx.build.PointerCast(fcx.llargs.get(va.id),
48224826
val_ty(lldestptr));
4823-
auto llargval = bcx.build.Load(llargptr);
48244827

4825-
bcx.build.Store(llargval, lldestptr);
4828+
auto arg_ty = arg_tys.(i).ty;
4829+
auto llargval;
4830+
if (ty.type_is_structural(arg_ty)) {
4831+
llargval = llargptr;
4832+
} else {
4833+
llargval = bcx.build.Load(llargptr);
4834+
}
4835+
4836+
rslt = copy_ty(bcx, INIT, lldestptr, llargval, arg_ty);
4837+
bcx = rslt.bcx;
4838+
48264839
i += 1u;
48274840
}
48284841

0 commit comments

Comments
 (0)