@@ -923,6 +923,18 @@ fn align_of(@block_ctxt cx, @ty.t t) -> result {
923
923
ret dynamic_align_of ( cx, t) ;
924
924
}
925
925
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
+
926
938
// Computes the size of the data part of a non-dynamically-sized tag.
927
939
fn static_size_of_tag ( @crate_ctxt cx , @ty. t t ) -> uint {
928
940
if ( ty. type_has_dynamic_size ( t) ) {
@@ -947,13 +959,19 @@ fn static_size_of_tag(@crate_ctxt cx, @ty.t t) -> uint {
947
959
}
948
960
}
949
961
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
+
950
965
// Compute max(variant sizes).
951
966
auto max_size = 0 u;
952
967
auto variants = tag_variants ( cx, tid) ;
953
968
for ( ast. variant variant in variants) {
954
969
let vec[ @ty. t] tys = variant_types ( cx, variant) ;
955
970
auto tup_ty = ty. plain_ty ( ty. ty_tup ( tys) ) ;
956
971
972
+ // Perform any type parameter substitutions.
973
+ tup_ty = ty. substitute_ty_params ( ty_params, subtys, tup_ty) ;
974
+
957
975
// Here we possibly do a recursive call.
958
976
auto this_size = llsize_of_real ( cx, type_of ( cx, tup_ty) ) ;
959
977
0 commit comments