Skip to content

Commit bd2a70b

Browse files
committed
---
yaml --- r: 1575 b: refs/heads/master c: 2986ed4 h: refs/heads/master i: 1573: 508b804 1571: a95df59 1567: 7a0063b v: v3
1 parent 71573e2 commit bd2a70b

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

[refs]

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 9aa26904b83266576f9a05d5b1b9ca99b8ed0533
2+
refs/heads/master: 2986ed43e9326d87e97072979a44ebe22e829d66

trunk/src/comp/middle/trans.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -1699,11 +1699,15 @@ fn variant_types(@crate_ctxt cx, &ast.variant v) -> vec[@ty.t] {
16991699
ret tys;
17001700
}
17011701

1702-
fn type_of_variant(@crate_ctxt cx, &ast.variant v) -> TypeRef {
1702+
fn type_of_variant(@crate_ctxt cx,
1703+
&ast.variant v,
1704+
vec[ast.ty_param] ty_params,
1705+
vec[@ty.t] ty_param_substs) -> TypeRef {
17031706
let vec[TypeRef] lltys = vec();
17041707
auto tys = variant_types(cx, v);
17051708
for (@ty.t typ in tys) {
1706-
lltys += vec(type_of(cx, typ));
1709+
auto typ2 = ty.substitute_ty_params(ty_params, ty_param_substs, typ);
1710+
lltys += vec(type_of(cx, typ2));
17071711
}
17081712
ret T_struct(lltys);
17091713
}
@@ -1850,6 +1854,8 @@ fn iter_structural_ty_full(@block_ctxt cx,
18501854

18511855
auto next_cx = new_sub_block_ctxt(bcx, "tag-iter-next");
18521856

1857+
auto ty_params = tag_ty_params(bcx.fcx.ccx, tid);
1858+
18531859
auto i = 0u;
18541860
for (ast.variant variant in variants) {
18551861
auto variant_cx = new_sub_block_ctxt(bcx,
@@ -1859,7 +1865,8 @@ fn iter_structural_ty_full(@block_ctxt cx,
18591865

18601866
if (_vec.len[ast.variant_arg](variant.args) > 0u) {
18611867
// N-ary variant.
1862-
auto llvarty = type_of_variant(bcx.fcx.ccx, variants.(i));
1868+
auto llvarty = type_of_variant(bcx.fcx.ccx, variants.(i),
1869+
ty_params, tps);
18631870

18641871
auto fn_ty = ty.ann_to_type(variants.(i).ann);
18651872
alt (fn_ty.struct) {
@@ -1870,8 +1877,6 @@ fn iter_structural_ty_full(@block_ctxt cx,
18701877
auto llvarp_b = variant_cx.build.
18711878
TruncOrBitCast(llunion_b_ptr, T_ptr(llvarty));
18721879

1873-
auto ty_params = tag_ty_params(bcx.fcx.ccx, tid);
1874-
18751880
auto j = 0u;
18761881
for (ty.arg a in args) {
18771882
auto v = vec(C_int(0), C_int(j as int));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
tag clam[T] {
2+
a(T);
3+
}
4+
5+
fn main() {
6+
auto c = a(3);
7+
}
8+

0 commit comments

Comments
 (0)