@@ -1434,6 +1434,9 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1434
1434
self . encode_info_for_assoc_item ( def_id) ;
1435
1435
}
1436
1436
}
1437
+ if let DefKind :: Impl { of_trait } = def_kind {
1438
+ self . encode_info_for_impl ( def_id, of_trait)
1439
+ }
1437
1440
if let DefKind :: Enum | DefKind :: Struct | DefKind :: Union = def_kind {
1438
1441
self . encode_info_for_adt ( local_id) ;
1439
1442
}
@@ -1705,32 +1708,9 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1705
1708
matches ! ( opaque. origin, hir:: OpaqueTyOrigin :: TyAlias { .. } ) ,
1706
1709
) ;
1707
1710
}
1708
- hir:: ItemKind :: Impl ( hir:: Impl { defaultness, .. } ) => {
1709
- self . tables . defaultness . set_some ( def_id. index , * defaultness) ;
1710
- self . tables . impl_polarity . set_some ( def_id. index , self . tcx . impl_polarity ( def_id) ) ;
1711
-
1712
- if let Some ( trait_ref) = self . tcx . impl_trait_ref ( def_id) {
1713
- record ! ( self . tables. impl_trait_ref[ def_id] <- trait_ref) ;
1714
-
1715
- let trait_ref = trait_ref. skip_binder ( ) ;
1716
- let trait_def = self . tcx . trait_def ( trait_ref. def_id ) ;
1717
- if let Ok ( mut an) = trait_def. ancestors ( self . tcx , def_id) {
1718
- if let Some ( specialization_graph:: Node :: Impl ( parent) ) = an. nth ( 1 ) {
1719
- self . tables . impl_parent . set_some ( def_id. index , parent. into ( ) ) ;
1720
- }
1721
- }
1722
-
1723
- // if this is an impl of `CoerceUnsized`, create its
1724
- // "unsized info", else just store None
1725
- if Some ( trait_ref. def_id ) == self . tcx . lang_items ( ) . coerce_unsized_trait ( ) {
1726
- let coerce_unsized_info =
1727
- self . tcx . at ( item. span ) . coerce_unsized_info ( def_id) ;
1728
- record ! ( self . tables. coerce_unsized_info[ def_id] <- coerce_unsized_info) ;
1729
- }
1730
- }
1731
- }
1732
1711
hir:: ItemKind :: ExternCrate ( _)
1733
1712
| hir:: ItemKind :: Use ( ..)
1713
+ | hir:: ItemKind :: Impl ( ..)
1734
1714
| hir:: ItemKind :: Trait ( ..)
1735
1715
| hir:: ItemKind :: TraitAlias ( ..)
1736
1716
| hir:: ItemKind :: Static ( ..)
@@ -1745,6 +1725,33 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1745
1725
}
1746
1726
}
1747
1727
1728
+ #[ tracing:: instrument( level = "debug" , skip( self ) ) ]
1729
+ fn encode_info_for_impl ( & mut self , def_id : DefId , of_trait : bool ) {
1730
+ let tcx = self . tcx ;
1731
+
1732
+ self . tables . defaultness . set_some ( def_id. index , tcx. defaultness ( def_id) ) ;
1733
+ self . tables . impl_polarity . set_some ( def_id. index , tcx. impl_polarity ( def_id) ) ;
1734
+
1735
+ if of_trait && let Some ( trait_ref) = tcx. impl_trait_ref ( def_id) {
1736
+ record ! ( self . tables. impl_trait_ref[ def_id] <- trait_ref) ;
1737
+
1738
+ let trait_def_id = trait_ref. skip_binder ( ) . def_id ;
1739
+ let trait_def = tcx. trait_def ( trait_def_id) ;
1740
+ if let Some ( mut an) = trait_def. ancestors ( tcx, def_id) . ok ( ) {
1741
+ if let Some ( specialization_graph:: Node :: Impl ( parent) ) = an. nth ( 1 ) {
1742
+ self . tables . impl_parent . set_some ( def_id. index , parent. into ( ) ) ;
1743
+ }
1744
+ }
1745
+
1746
+ // if this is an impl of `CoerceUnsized`, create its
1747
+ // "unsized info", else just store None
1748
+ if Some ( trait_def_id) == tcx. lang_items ( ) . coerce_unsized_trait ( ) {
1749
+ let coerce_unsized_info = tcx. coerce_unsized_info ( def_id) ;
1750
+ record ! ( self . tables. coerce_unsized_info[ def_id] <- coerce_unsized_info) ;
1751
+ }
1752
+ }
1753
+ }
1754
+
1748
1755
#[ instrument( level = "debug" , skip( self ) ) ]
1749
1756
fn encode_info_for_generator ( & mut self , def_id : LocalDefId ) {
1750
1757
let typeck_result: & ' tcx ty:: TypeckResults < ' tcx > = self . tcx . typeck ( def_id) ;
0 commit comments