Skip to content

Commit 508b804

Browse files
committed
---
yaml --- r: 1573 b: refs/heads/master c: 80fa01f h: refs/heads/master i: 1571: a95df59 v: v3
1 parent 7bf144d commit 508b804

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

[refs]

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: fcd195bb4ca47d4b3c7dfd3e6c14dc5771e139cc
2+
refs/heads/master: 80fa01fb5784b91c05443daff0df6c607c2ce276

trunk/src/comp/middle/trans.rs

+18
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,18 @@ fn align_of(@block_ctxt cx, @ty.t t) -> result {
923923
ret dynamic_align_of(cx, t);
924924
}
925925

926+
// Returns the type parameters associated with the tag with the given ID.
927+
fn ty_params_of_tag(@crate_ctxt cx, &ast.def_id tid) -> vec[ast.ty_param] {
928+
alt (cx.items.get(tid).node) {
929+
case (ast.item_tag(_, _, ?tps, _)) { ret tps; }
930+
case (_) {
931+
log "ty_params_of_tag(): tag ID doesn't actually refer to a " +
932+
"tag item";
933+
fail;
934+
}
935+
}
936+
}
937+
926938
// Computes the size of the data part of a non-dynamically-sized tag.
927939
fn static_size_of_tag(@crate_ctxt cx, @ty.t t) -> uint {
928940
if (ty.type_has_dynamic_size(t)) {
@@ -947,13 +959,19 @@ fn static_size_of_tag(@crate_ctxt cx, @ty.t t) -> uint {
947959
}
948960
}
949961

962+
// Pull the type parameters out of the corresponding tag item.
963+
let vec[ast.ty_param] ty_params = ty_params_of_tag(cx, tid);
964+
950965
// Compute max(variant sizes).
951966
auto max_size = 0u;
952967
auto variants = tag_variants(cx, tid);
953968
for (ast.variant variant in variants) {
954969
let vec[@ty.t] tys = variant_types(cx, variant);
955970
auto tup_ty = ty.plain_ty(ty.ty_tup(tys));
956971

972+
// Perform any type parameter substitutions.
973+
tup_ty = ty.substitute_ty_params(ty_params, subtys, tup_ty);
974+
957975
// Here we possibly do a recursive call.
958976
auto this_size = llsize_of_real(cx, type_of(cx, tup_ty));
959977

0 commit comments

Comments
 (0)