Skip to content

Commit e37db13

Browse files
committed
rustc: Eliminate the "ty_params" field from the tag info
1 parent 699eb69 commit e37db13

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/comp/middle/trans.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ type glue_fns = rec(ValueRef activate_glue,
6060
ValueRef bzero_glue);
6161

6262
tag arity { nullary; n_ary; }
63-
type tag_info = rec(type_handle th,
64-
mutable uint size,
65-
vec[ast.ty_param] ty_params);
63+
type tag_info = rec(type_handle th, mutable uint size);
6664

6765
state type crate_ctxt = rec(session.session sess,
6866
ModuleRef llmod,
@@ -1456,6 +1454,15 @@ fn type_of_variant(@crate_ctxt cx, &ast.variant v) -> TypeRef {
14561454
ret T_struct(lltys);
14571455
}
14581456

1457+
// Returns the type parameters of a tag.
1458+
fn tag_ty_params(@crate_ctxt cx, ast.def_id id) -> vec[ast.ty_param] {
1459+
check (cx.items.contains_key(id));
1460+
alt (cx.items.get(id).node) {
1461+
case (ast.item_tag(_, _, ?tps, _)) { ret tps; }
1462+
}
1463+
fail; // not reached
1464+
}
1465+
14591466
// Returns the variants in a tag.
14601467
fn tag_variants(@crate_ctxt cx, ast.def_id id) -> vec[ast.variant] {
14611468
check (cx.items.contains_key(id));
@@ -1551,13 +1558,15 @@ fn iter_structural_ty(@block_ctxt cx,
15511558
auto llvarp = variant_cx.build.
15521559
TruncOrBitCast(llunion_ptr, T_ptr(llvarty));
15531560

1561+
auto ty_params = tag_ty_params(cx.fcx.ccx, tid);
1562+
15541563
auto j = 0u;
15551564
for (ty.arg a in args) {
15561565
auto v = vec(C_int(0), C_int(j as int));
15571566
auto llfldp = variant_cx.build.GEP(llvarp, v);
15581567

15591568
auto ty_subst = ty.substitute_ty_params(
1560-
info.ty_params, tps, a.ty);
1569+
ty_params, tps, a.ty);
15611570

15621571
auto llfld =
15631572
load_scalar_or_boxed(variant_cx,
@@ -4437,8 +4446,7 @@ fn collect_item(&@crate_ctxt cx, @ast.item i) -> @crate_ctxt {
44374446
auto vi = new_def_hash[uint]();
44384447
auto navi = new_def_hash[uint]();
44394448
cx.tags.insert(tag_id, @rec(th=mk_type_handle(),
4440-
mutable size=0u,
4441-
ty_params=tps));
4449+
mutable size=0u));
44424450
cx.items.insert(tag_id, i);
44434451
}
44444452

0 commit comments

Comments
 (0)