@@ -452,38 +452,37 @@ impl<'a, 'tcx, 'encoder> ItemContentBuilder<'a, 'tcx, 'encoder> {
452
452
}
453
453
}
454
454
455
- impl < ' a , ' tcx , ' encoder > IndexBuilder < ' a , ' tcx , ' encoder > {
456
- fn encode_info_for_struct_ctor ( & mut self ,
457
- name : Name ,
458
- ctor_id : ast:: NodeId ,
459
- variant : ty:: VariantDef < ' tcx > ,
460
- struct_id : NodeId ) {
455
+ impl < ' a , ' tcx , ' encoder > ItemContentBuilder < ' a , ' tcx , ' encoder > {
456
+ fn encode_struct_ctor ( & mut self ,
457
+ struct_def_id : DefId ,
458
+ struct_node_id : ast:: NodeId ,
459
+ ctor_node_id : ast:: NodeId ) {
461
460
let ecx = self . ecx ( ) ;
462
- let ctor_def_id = ecx. tcx . map . local_def_id ( ctor_id) ;
463
-
464
- self . record ( ctor_def_id, |this| {
465
- encode_def_id_and_key ( ecx, this. rbml_w , ctor_def_id) ;
466
- encode_family ( this. rbml_w , match variant. kind {
467
- ty:: VariantKind :: Struct => 'S' ,
468
- ty:: VariantKind :: Tuple => 's' ,
469
- ty:: VariantKind :: Unit => 'u' ,
470
- } ) ;
471
- this. encode_bounds_and_type_for_item ( ctor_id) ;
472
- encode_name ( this. rbml_w , name) ;
473
- this. encode_parent_item ( ecx. tcx . map . local_def_id ( struct_id) ) ;
461
+ let def = ecx. tcx . lookup_adt_def ( struct_def_id) ;
462
+ let variant = def. struct_variant ( ) ;
463
+ let item = ecx. tcx . map . expect_item ( struct_node_id) ;
464
+ let ctor_def_id = ecx. tcx . map . local_def_id ( ctor_node_id) ;
465
+ encode_def_id_and_key ( ecx, self . rbml_w , ctor_def_id) ;
466
+ encode_family ( self . rbml_w , match variant. kind {
467
+ ty:: VariantKind :: Struct => 'S' ,
468
+ ty:: VariantKind :: Tuple => 's' ,
469
+ ty:: VariantKind :: Unit => 'u' ,
470
+ } ) ;
471
+ self . encode_bounds_and_type_for_item ( ctor_node_id) ;
472
+ encode_name ( self . rbml_w , item. name ) ;
473
+ self . encode_parent_item ( struct_def_id) ;
474
474
475
- let stab = ecx. tcx . lookup_stability ( ecx . tcx . map . local_def_id ( ctor_id ) ) ;
476
- let depr = ecx. tcx . lookup_deprecation ( ecx . tcx . map . local_def_id ( ctor_id ) ) ;
477
- encode_stability ( this . rbml_w , stab) ;
478
- encode_deprecation ( this . rbml_w , depr) ;
475
+ let stab = ecx. tcx . lookup_stability ( ctor_def_id ) ;
476
+ let depr = ecx. tcx . lookup_deprecation ( ctor_def_id ) ;
477
+ encode_stability ( self . rbml_w , stab) ;
478
+ encode_deprecation ( self . rbml_w , depr) ;
479
479
480
- // indicate that this is a tuple struct ctor, because
481
- // downstream users will normally want the tuple struct
482
- // definition, but without this there is no way for them
483
- // to tell that they actually have a ctor rather than a
484
- // normal function
485
- this. rbml_w . wr_tagged_bytes ( tag_items_data_item_is_tuple_struct_ctor, & [ ] ) ;
486
- } ) ;
480
+ // indicate that this is a tuple struct ctor, because
481
+ // downstream users will normally want the tuple struct
482
+ // definition, but without this there is no way for them
483
+ // to tell that they actually have a ctor rather than a
484
+ // normal function
485
+ self . rbml_w . wr_tagged_bytes ( tag_items_data_item_is_tuple_struct_ctor, & [ ] ) ;
487
486
}
488
487
}
489
488
@@ -1073,7 +1072,7 @@ impl<'a, 'tcx, 'encoder> IndexBuilder<'a, 'tcx, 'encoder> {
1073
1072
1074
1073
fn encode_addl_struct_info ( & mut self ,
1075
1074
def_id : DefId ,
1076
- struct_def_id : ast:: NodeId ,
1075
+ struct_node_id : ast:: NodeId ,
1077
1076
item : & hir:: Item ) {
1078
1077
let ecx = self . ecx ;
1079
1078
let def = ecx. tcx . lookup_adt_def ( def_id) ;
@@ -1089,10 +1088,10 @@ impl<'a, 'tcx, 'encoder> IndexBuilder<'a, 'tcx, 'encoder> {
1089
1088
ty:: VariantKind :: Tuple | ty:: VariantKind :: Unit => {
1090
1089
// there is a value for structs like `struct
1091
1090
// Foo()` and `struct Foo`
1092
- self . encode_info_for_struct_ctor ( item . name ,
1093
- struct_def_id ,
1094
- variant ,
1095
- item . id ) ;
1091
+ let ctor_def_id = ecx . tcx . map . local_def_id ( struct_node_id ) ;
1092
+ self . record ( ctor_def_id , |this| this . encode_struct_ctor ( def_id ,
1093
+ item . id ,
1094
+ struct_node_id ) ) ;
1096
1095
}
1097
1096
}
1098
1097
}
0 commit comments