@@ -307,6 +307,27 @@ fn encode_parent_item(ebml_w: &mut writer::Encoder, id: DefId) {
307
307
ebml_w. end_tag ( ) ;
308
308
}
309
309
310
+ fn encode_struct_fields ( ecx : & EncodeContext ,
311
+ ebml_w : & mut writer:: Encoder ,
312
+ def : @struct_def ) {
313
+ for f in def. fields . iter ( ) {
314
+ match f. node . kind {
315
+ named_field( ident, vis) => {
316
+ ebml_w. start_tag ( tag_item_field) ;
317
+ encode_struct_field_family ( ebml_w, vis) ;
318
+ encode_name ( ecx, ebml_w, ident) ;
319
+ encode_def_id ( ebml_w, local_def ( f. node . id ) ) ;
320
+ ebml_w. end_tag ( ) ;
321
+ }
322
+ unnamed_field => {
323
+ ebml_w. start_tag ( tag_item_unnamed_field) ;
324
+ encode_def_id ( ebml_w, local_def ( f. node . id ) ) ;
325
+ ebml_w. end_tag ( ) ;
326
+ }
327
+ }
328
+ }
329
+ }
330
+
310
331
fn encode_enum_variant_info ( ecx : & EncodeContext ,
311
332
ebml_w : & mut writer:: Encoder ,
312
333
id : NodeId ,
@@ -326,7 +347,10 @@ fn encode_enum_variant_info(ecx: &EncodeContext,
326
347
pos : ebml_w. writer . tell ( ) } ) ;
327
348
ebml_w. start_tag ( tag_items_data_item) ;
328
349
encode_def_id ( ebml_w, def_id) ;
329
- encode_family ( ebml_w, 'v' ) ;
350
+ match variant. node . kind {
351
+ ast:: tuple_variant_kind( _) => encode_family ( ebml_w, 'v' ) ,
352
+ ast:: struct_variant_kind( _) => encode_family ( ebml_w, 'V' )
353
+ }
330
354
encode_name ( ecx, ebml_w, variant. node . name ) ;
331
355
encode_parent_item ( ebml_w, local_def ( id) ) ;
332
356
encode_visibility ( ebml_w, variant. node . vis ) ;
@@ -336,7 +360,14 @@ fn encode_enum_variant_info(ecx: &EncodeContext,
336
360
if args. len ( ) > 0 && generics. ty_params . len ( ) == 0 => {
337
361
encode_symbol ( ecx, ebml_w, variant. node . id ) ;
338
362
}
339
- ast:: tuple_variant_kind( _) | ast:: struct_variant_kind( _) => { }
363
+ ast:: tuple_variant_kind( _) => { } ,
364
+ ast:: struct_variant_kind( def) => {
365
+ let idx = encode_info_for_struct ( ecx, ebml_w, path,
366
+ def. fields , index) ;
367
+ encode_struct_fields ( ecx, ebml_w, def) ;
368
+ let bkts = create_index ( idx) ;
369
+ encode_index ( ebml_w, bkts, write_i64) ;
370
+ }
340
371
}
341
372
if vi[ i] . disr_val != disr_val {
342
373
encode_disr_val ( ecx, ebml_w, vi[ i] . disr_val ) ;
@@ -986,22 +1017,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
986
1017
/* Encode def_ids for each field and method
987
1018
for methods, write all the stuff get_trait_method
988
1019
needs to know*/
989
- for f in struct_def. fields . iter ( ) {
990
- match f. node . kind {
991
- named_field( ident, vis) => {
992
- ebml_w. start_tag ( tag_item_field) ;
993
- encode_struct_field_family ( ebml_w, vis) ;
994
- encode_name ( ecx, ebml_w, ident) ;
995
- encode_def_id ( ebml_w, local_def ( f. node . id ) ) ;
996
- ebml_w. end_tag ( ) ;
997
- }
998
- unnamed_field => {
999
- ebml_w. start_tag ( tag_item_unnamed_field) ;
1000
- encode_def_id ( ebml_w, local_def ( f. node . id ) ) ;
1001
- ebml_w. end_tag ( ) ;
1002
- }
1003
- }
1004
- }
1020
+ encode_struct_fields ( ecx, ebml_w, struct_def) ;
1005
1021
1006
1022
// Encode inherent implementations for this structure.
1007
1023
encode_inherent_implementations ( ecx, ebml_w, def_id) ;
0 commit comments