@@ -530,7 +530,31 @@ impl<'a, 'tcx, 'encoder> ItemContentBuilder<'a, 'tcx, 'encoder> {
530
530
}
531
531
}
532
532
533
- impl < ' a , ' tcx , ' encoder > IndexBuilder < ' a , ' tcx , ' encoder > {
533
+ impl < ' a , ' tcx , ' encoder > ItemContentBuilder < ' a , ' tcx , ' encoder > {
534
+ fn encode_info_for_impl_item ( & mut self ,
535
+ impl_id : NodeId ,
536
+ impl_item_def_id : DefId ,
537
+ ast_item : Option < & hir:: ImplItem > ) {
538
+ match self . ecx . tcx . impl_or_trait_item ( impl_item_def_id) {
539
+ ty:: ConstTraitItem ( ref associated_const) => {
540
+ self . encode_info_for_associated_const ( & associated_const,
541
+ impl_id,
542
+ ast_item)
543
+ }
544
+ ty:: MethodTraitItem ( ref method_type) => {
545
+ self . encode_info_for_method ( & method_type,
546
+ false ,
547
+ impl_id,
548
+ ast_item)
549
+ }
550
+ ty:: TypeTraitItem ( ref associated_type) => {
551
+ self . encode_info_for_associated_type ( & associated_type,
552
+ impl_id,
553
+ ast_item)
554
+ }
555
+ }
556
+ }
557
+
534
558
fn encode_info_for_associated_const ( & mut self ,
535
559
associated_const : & ty:: AssociatedConst ,
536
560
parent_id : NodeId ,
@@ -540,32 +564,30 @@ impl<'a, 'tcx, 'encoder> IndexBuilder<'a, 'tcx, 'encoder> {
540
564
associated_const. def_id,
541
565
associated_const. name) ;
542
566
543
- self . record ( associated_const. def_id , |this| {
544
- encode_def_id_and_key ( ecx, this. rbml_w , associated_const. def_id ) ;
545
- encode_name ( this. rbml_w , associated_const. name ) ;
546
- this. encode_visibility ( associated_const. vis ) ;
547
- encode_family ( this. rbml_w , 'C' ) ;
567
+ encode_def_id_and_key ( ecx, self . rbml_w , associated_const. def_id ) ;
568
+ encode_name ( self . rbml_w , associated_const. name ) ;
569
+ self . encode_visibility ( associated_const. vis ) ;
570
+ encode_family ( self . rbml_w , 'C' ) ;
548
571
549
- this. encode_parent_item ( ecx. tcx . map . local_def_id ( parent_id) ) ;
550
- encode_item_sort ( this. rbml_w , 'C' ) ;
551
-
552
- this. encode_bounds_and_type_for_item ( ecx. local_id ( associated_const. def_id ) ) ;
553
-
554
- let stab = ecx. tcx . lookup_stability ( associated_const. def_id ) ;
555
- let depr = ecx. tcx . lookup_deprecation ( associated_const. def_id ) ;
556
- encode_stability ( this. rbml_w , stab) ;
557
- encode_deprecation ( this. rbml_w , depr) ;
558
-
559
- if let Some ( ii) = impl_item_opt {
560
- encode_attributes ( this. rbml_w , & ii. attrs ) ;
561
- encode_defaultness ( this. rbml_w , ii. defaultness ) ;
562
- encode_inlined_item ( ecx,
563
- this. rbml_w ,
564
- InlinedItemRef :: ImplItem ( ecx. tcx . map . local_def_id ( parent_id) ,
565
- ii) ) ;
566
- this. encode_mir ( ii. id ) ;
567
- }
568
- } ) ;
572
+ self . encode_parent_item ( ecx. tcx . map . local_def_id ( parent_id) ) ;
573
+ encode_item_sort ( self . rbml_w , 'C' ) ;
574
+
575
+ self . encode_bounds_and_type_for_item ( ecx. local_id ( associated_const. def_id ) ) ;
576
+
577
+ let stab = ecx. tcx . lookup_stability ( associated_const. def_id ) ;
578
+ let depr = ecx. tcx . lookup_deprecation ( associated_const. def_id ) ;
579
+ encode_stability ( self . rbml_w , stab) ;
580
+ encode_deprecation ( self . rbml_w , depr) ;
581
+
582
+ if let Some ( ii) = impl_item_opt {
583
+ encode_attributes ( self . rbml_w , & ii. attrs ) ;
584
+ encode_defaultness ( self . rbml_w , ii. defaultness ) ;
585
+ encode_inlined_item ( ecx,
586
+ self . rbml_w ,
587
+ InlinedItemRef :: ImplItem ( ecx. tcx . map . local_def_id ( parent_id) ,
588
+ ii) ) ;
589
+ self . encode_mir ( ii. id ) ;
590
+ }
569
591
}
570
592
571
593
fn encode_info_for_method ( & mut self ,
@@ -577,40 +599,38 @@ impl<'a, 'tcx, 'encoder> IndexBuilder<'a, 'tcx, 'encoder> {
577
599
578
600
debug ! ( "encode_info_for_method: {:?} {:?}" , m. def_id,
579
601
m. name) ;
580
- self . record ( m. def_id , |this| {
581
- this. encode_method_ty_fields ( m) ;
582
- this. encode_parent_item ( ecx. tcx . map . local_def_id ( parent_id) ) ;
583
- encode_item_sort ( this. rbml_w , 'r' ) ;
584
-
585
- let stab = ecx. tcx . lookup_stability ( m. def_id ) ;
586
- let depr = ecx. tcx . lookup_deprecation ( m. def_id ) ;
587
- encode_stability ( this. rbml_w , stab) ;
588
- encode_deprecation ( this. rbml_w , depr) ;
589
-
590
- let m_node_id = ecx. local_id ( m. def_id ) ;
591
- this. encode_bounds_and_type_for_item ( m_node_id) ;
592
-
593
- if let Some ( impl_item) = impl_item_opt {
594
- if let hir:: ImplItemKind :: Method ( ref sig, _) = impl_item. node {
595
- encode_attributes ( this. rbml_w , & impl_item. attrs ) ;
596
- let generics = ecx. tcx . lookup_generics ( m. def_id ) ;
597
- let types = generics. parent_types as usize + generics. types . len ( ) ;
598
- let needs_inline = types > 0 || is_default_impl ||
599
- attr:: requests_inline ( & impl_item. attrs ) ;
600
- if needs_inline || sig. constness == hir:: Constness :: Const {
601
- encode_inlined_item (
602
- ecx,
603
- this. rbml_w ,
604
- InlinedItemRef :: ImplItem ( ecx. tcx . map . local_def_id ( parent_id) ,
605
- impl_item) ) ;
606
- this. encode_mir ( impl_item. id ) ;
607
- }
608
- encode_constness ( this. rbml_w , sig. constness ) ;
609
- encode_defaultness ( this. rbml_w , impl_item. defaultness ) ;
610
- this. encode_method_argument_names ( & sig. decl ) ;
602
+ self . encode_method_ty_fields ( m) ;
603
+ self . encode_parent_item ( ecx. tcx . map . local_def_id ( parent_id) ) ;
604
+ encode_item_sort ( self . rbml_w , 'r' ) ;
605
+
606
+ let stab = ecx. tcx . lookup_stability ( m. def_id ) ;
607
+ let depr = ecx. tcx . lookup_deprecation ( m. def_id ) ;
608
+ encode_stability ( self . rbml_w , stab) ;
609
+ encode_deprecation ( self . rbml_w , depr) ;
610
+
611
+ let m_node_id = ecx. local_id ( m. def_id ) ;
612
+ self . encode_bounds_and_type_for_item ( m_node_id) ;
613
+
614
+ if let Some ( impl_item) = impl_item_opt {
615
+ if let hir:: ImplItemKind :: Method ( ref sig, _) = impl_item. node {
616
+ encode_attributes ( self . rbml_w , & impl_item. attrs ) ;
617
+ let generics = ecx. tcx . lookup_generics ( m. def_id ) ;
618
+ let types = generics. parent_types as usize + generics. types . len ( ) ;
619
+ let needs_inline = types > 0 || is_default_impl ||
620
+ attr:: requests_inline ( & impl_item. attrs ) ;
621
+ if needs_inline || sig. constness == hir:: Constness :: Const {
622
+ encode_inlined_item (
623
+ ecx,
624
+ self . rbml_w ,
625
+ InlinedItemRef :: ImplItem ( ecx. tcx . map . local_def_id ( parent_id) ,
626
+ impl_item) ) ;
627
+ self . encode_mir ( impl_item. id ) ;
611
628
}
629
+ encode_constness ( self . rbml_w , sig. constness ) ;
630
+ encode_defaultness ( self . rbml_w , impl_item. defaultness ) ;
631
+ self . encode_method_argument_names ( & sig. decl ) ;
612
632
}
613
- } ) ;
633
+ }
614
634
}
615
635
616
636
fn encode_info_for_associated_type ( & mut self ,
@@ -622,32 +642,30 @@ impl<'a, 'tcx, 'encoder> IndexBuilder<'a, 'tcx, 'encoder> {
622
642
associated_type. def_id,
623
643
associated_type. name) ;
624
644
625
- self . record ( associated_type. def_id , |this| {
626
- encode_def_id_and_key ( ecx, this. rbml_w , associated_type. def_id ) ;
627
- encode_name ( this. rbml_w , associated_type. name ) ;
628
- this. encode_visibility ( associated_type. vis ) ;
629
- encode_family ( this. rbml_w , 'y' ) ;
630
- this. encode_parent_item ( ecx. tcx . map . local_def_id ( parent_id) ) ;
631
- encode_item_sort ( this. rbml_w , 't' ) ;
645
+ encode_def_id_and_key ( ecx, self . rbml_w , associated_type. def_id ) ;
646
+ encode_name ( self . rbml_w , associated_type. name ) ;
647
+ self . encode_visibility ( associated_type. vis ) ;
648
+ encode_family ( self . rbml_w , 'y' ) ;
649
+ self . encode_parent_item ( ecx. tcx . map . local_def_id ( parent_id) ) ;
650
+ encode_item_sort ( self . rbml_w , 't' ) ;
632
651
633
- let stab = ecx. tcx . lookup_stability ( associated_type. def_id ) ;
634
- let depr = ecx. tcx . lookup_deprecation ( associated_type. def_id ) ;
635
- encode_stability ( this . rbml_w , stab) ;
636
- encode_deprecation ( this . rbml_w , depr) ;
652
+ let stab = ecx. tcx . lookup_stability ( associated_type. def_id ) ;
653
+ let depr = ecx. tcx . lookup_deprecation ( associated_type. def_id ) ;
654
+ encode_stability ( self . rbml_w , stab) ;
655
+ encode_deprecation ( self . rbml_w , depr) ;
637
656
638
- if let Some ( ii) = impl_item_opt {
639
- encode_attributes ( this . rbml_w , & ii. attrs ) ;
640
- encode_defaultness ( this . rbml_w , ii. defaultness ) ;
641
- } else {
642
- // TODO this looks bogus and unnecessary
643
- this . encode_predicates ( & ecx. tcx . lookup_predicates ( associated_type. def_id ) ,
644
- tag_item_generics) ;
645
- }
657
+ if let Some ( ii) = impl_item_opt {
658
+ encode_attributes ( self . rbml_w , & ii. attrs ) ;
659
+ encode_defaultness ( self . rbml_w , ii. defaultness ) ;
660
+ } else {
661
+ // TODO this looks bogus and unnecessary
662
+ self . encode_predicates ( & ecx. tcx . lookup_predicates ( associated_type. def_id ) ,
663
+ tag_item_generics) ;
664
+ }
646
665
647
- if let Some ( ty) = associated_type. ty {
648
- this. encode_type ( ty) ;
649
- }
650
- } ) ;
666
+ if let Some ( ty) = associated_type. ty {
667
+ self . encode_type ( ty) ;
668
+ }
651
669
}
652
670
}
653
671
@@ -1116,24 +1134,10 @@ impl<'a, 'tcx, 'encoder> IndexBuilder<'a, 'tcx, 'encoder> {
1116
1134
None
1117
1135
} ;
1118
1136
1119
- match self . ecx . tcx . impl_or_trait_item ( trait_item_def_id. def_id ( ) ) {
1120
- ty:: ConstTraitItem ( ref associated_const) => {
1121
- self . encode_info_for_associated_const ( & associated_const,
1122
- impl_id,
1123
- ast_item)
1124
- }
1125
- ty:: MethodTraitItem ( ref method_type) => {
1126
- self . encode_info_for_method ( & method_type,
1127
- false ,
1128
- impl_id,
1129
- ast_item)
1130
- }
1131
- ty:: TypeTraitItem ( ref associated_type) => {
1132
- self . encode_info_for_associated_type ( & associated_type,
1133
- impl_id,
1134
- ast_item)
1135
- }
1136
- }
1137
+ let trait_item_def_id = trait_item_def_id. def_id ( ) ;
1138
+ self . record ( trait_item_def_id, |this| {
1139
+ this. encode_info_for_impl_item ( impl_id, trait_item_def_id, ast_item)
1140
+ } ) ;
1137
1141
}
1138
1142
}
1139
1143
0 commit comments