@@ -1007,12 +1007,43 @@ fn encode_info_for_item(ecx: &EncodeContext,
1007
1007
generics) ;
1008
1008
}
1009
1009
ItemStruct ( struct_def, _) => {
1010
+ // Create a list of all structs which compose this struct. That is, the
1011
+ // reflexive, transitive closure over struct_def's super-struct.
1012
+ let mut cur_struct = struct_def;
1013
+ let mut structs: ~[ @StructDef ] = ~[ ] ;
1014
+ loop {
1015
+ structs. push ( cur_struct) ;
1016
+ match cur_struct. super_struct {
1017
+ Some ( t) => match t. node {
1018
+ ast:: TyPath ( _, _, path_id) => {
1019
+ let def_map = tcx. def_map . borrow ( ) ;
1020
+ match def_map. get ( ) . find ( & path_id) {
1021
+ Some ( & DefStruct ( def_id) ) => {
1022
+ cur_struct = match tcx. map . find ( def_id. node ) {
1023
+ Some ( ast_map:: NodeItem ( i) ) => {
1024
+ match i. node {
1025
+ ast:: ItemStruct ( struct_def, _) => struct_def,
1026
+ _ => ecx. diag . handler ( ) . bug ( "Expected ItemStruct" ) ,
1027
+ }
1028
+ } ,
1029
+ _ => ecx. diag . handler ( ) . bug ( "Expected NodeItem" ) ,
1030
+ } ;
1031
+ } ,
1032
+ _ => ecx. diag . handler ( ) . bug ( "Expected DefStruct" ) ,
1033
+ }
1034
+ }
1035
+ _ => ecx. diag . handler ( ) . bug ( "Expected TyPath" ) ,
1036
+ } ,
1037
+ None => break ,
1038
+ }
1039
+ }
1040
+
1010
1041
/* First, encode the fields
1011
1042
These come first because we need to write them to make
1012
1043
the index, and the index needs to be in the item for the
1013
1044
class itself */
1014
- let idx = encode_info_for_struct ( ecx , ebml_w ,
1015
- struct_def . fields , index) ;
1045
+ let idx = structs . iter ( ) . fold ( ~ [ ] , | a : ~ [ entry < i64 > ] , & s|
1046
+ a + encode_info_for_struct ( ecx , ebml_w , s . fields , index) ) ;
1016
1047
1017
1048
/* Index the class*/
1018
1049
add_to_index ( item, ebml_w, index) ;
@@ -1032,7 +1063,10 @@ fn encode_info_for_item(ecx: &EncodeContext,
1032
1063
/* Encode def_ids for each field and method
1033
1064
for methods, write all the stuff get_trait_method
1034
1065
needs to know*/
1035
- encode_struct_fields ( ebml_w, struct_def) ;
1066
+ structs. iter ( ) . advance ( |& s| {
1067
+ encode_struct_fields ( ebml_w, s) ;
1068
+ true
1069
+ } ) ;
1036
1070
1037
1071
( ecx. encode_inlined_item ) ( ecx, ebml_w, IIItemRef ( item) ) ;
1038
1072
0 commit comments