@@ -1417,9 +1417,6 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1417
1417
record ! ( self . tables. super_predicates_of[ def_id] <- self . tcx. super_predicates_of( def_id) ) ;
1418
1418
record ! ( self . tables. implied_predicates_of[ def_id] <- self . tcx. implied_predicates_of( def_id) ) ;
1419
1419
}
1420
- if let DefKind :: Generator = def_kind {
1421
- self . encode_info_for_generator ( local_id) ;
1422
- }
1423
1420
if let DefKind :: Trait | DefKind :: Impl { .. } = def_kind {
1424
1421
let associated_item_def_ids = self . tcx . associated_item_def_ids ( def_id) ;
1425
1422
record_array ! ( self . tables. associated_item_or_field_def_ids[ def_id] <-
@@ -1432,8 +1429,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1432
1429
self . encode_info_for_assoc_item ( def_id) ;
1433
1430
}
1434
1431
}
1435
- if let DefKind :: Impl { of_trait } = def_kind {
1436
- self . encode_info_for_impl ( def_id , of_trait )
1432
+ if let DefKind :: Generator = def_kind {
1433
+ self . encode_info_for_generator ( local_id ) ;
1437
1434
}
1438
1435
if let DefKind :: Enum | DefKind :: Struct | DefKind :: Union = def_kind {
1439
1436
self . encode_info_for_adt ( local_id) ;
@@ -1705,33 +1702,6 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1705
1702
record ! ( self . tables. macro_definition[ def_id. to_def_id( ) ] <- & * macro_def. body) ;
1706
1703
}
1707
1704
1708
- #[ instrument( level = "debug" , skip( self ) ) ]
1709
- fn encode_info_for_impl ( & mut self , def_id : DefId , of_trait : bool ) {
1710
- let tcx = self . tcx ;
1711
-
1712
- self . tables . defaultness . set_some ( def_id. index , tcx. defaultness ( def_id) ) ;
1713
- self . tables . impl_polarity . set_some ( def_id. index , tcx. impl_polarity ( def_id) ) ;
1714
-
1715
- if of_trait && let Some ( trait_ref) = tcx. impl_trait_ref ( def_id) {
1716
- record ! ( self . tables. impl_trait_ref[ def_id] <- trait_ref) ;
1717
-
1718
- let trait_def_id = trait_ref. skip_binder ( ) . def_id ;
1719
- let trait_def = tcx. trait_def ( trait_def_id) ;
1720
- if let Some ( mut an) = trait_def. ancestors ( tcx, def_id) . ok ( ) {
1721
- if let Some ( specialization_graph:: Node :: Impl ( parent) ) = an. nth ( 1 ) {
1722
- self . tables . impl_parent . set_some ( def_id. index , parent. into ( ) ) ;
1723
- }
1724
- }
1725
-
1726
- // if this is an impl of `CoerceUnsized`, create its
1727
- // "unsized info", else just store None
1728
- if Some ( trait_def_id) == tcx. lang_items ( ) . coerce_unsized_trait ( ) {
1729
- let coerce_unsized_info = tcx. coerce_unsized_info ( def_id) ;
1730
- record ! ( self . tables. coerce_unsized_info[ def_id] <- coerce_unsized_info) ;
1731
- }
1732
- }
1733
- }
1734
-
1735
1705
#[ instrument( level = "debug" , skip( self ) ) ]
1736
1706
fn encode_info_for_generator ( & mut self , def_id : LocalDefId ) {
1737
1707
let typeck_result: & ' tcx ty:: TypeckResults < ' tcx > = self . tcx . typeck ( def_id) ;
@@ -1967,20 +1937,35 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1967
1937
FxHashMap :: default ( ) ;
1968
1938
1969
1939
for id in tcx. hir ( ) . items ( ) {
1970
- if matches ! ( tcx. def_kind( id. owner_id) , DefKind :: Impl { .. } ) {
1971
- if let Some ( trait_ref) = tcx. impl_trait_ref ( id. owner_id ) {
1972
- let trait_ref = trait_ref. subst_identity ( ) ;
1973
-
1974
- let simplified_self_ty = fast_reject:: simplify_type (
1975
- self . tcx ,
1976
- trait_ref. self_ty ( ) ,
1977
- TreatParams :: AsCandidateKey ,
1978
- ) ;
1979
-
1980
- fx_hash_map
1981
- . entry ( trait_ref. def_id )
1982
- . or_default ( )
1983
- . push ( ( id. owner_id . def_id . local_def_index , simplified_self_ty) ) ;
1940
+ let DefKind :: Impl { of_trait } = tcx. def_kind ( id. owner_id ) else { continue ; } ;
1941
+ let def_id = id. owner_id . to_def_id ( ) ;
1942
+
1943
+ self . tables . defaultness . set_some ( def_id. index , tcx. defaultness ( def_id) ) ;
1944
+ self . tables . impl_polarity . set_some ( def_id. index , tcx. impl_polarity ( def_id) ) ;
1945
+
1946
+ if of_trait && let Some ( trait_ref) = tcx. impl_trait_ref ( def_id) {
1947
+ record ! ( self . tables. impl_trait_ref[ def_id] <- trait_ref) ;
1948
+
1949
+ let trait_ref = trait_ref. subst_identity ( ) ;
1950
+ let simplified_self_ty =
1951
+ fast_reject:: simplify_type ( self . tcx , trait_ref. self_ty ( ) , TreatParams :: AsCandidateKey ) ;
1952
+ fx_hash_map
1953
+ . entry ( trait_ref. def_id )
1954
+ . or_default ( )
1955
+ . push ( ( id. owner_id . def_id . local_def_index , simplified_self_ty) ) ;
1956
+
1957
+ let trait_def = tcx. trait_def ( trait_ref. def_id ) ;
1958
+ if let Some ( mut an) = trait_def. ancestors ( tcx, def_id) . ok ( ) {
1959
+ if let Some ( specialization_graph:: Node :: Impl ( parent) ) = an. nth ( 1 ) {
1960
+ self . tables . impl_parent . set_some ( def_id. index , parent. into ( ) ) ;
1961
+ }
1962
+ }
1963
+
1964
+ // if this is an impl of `CoerceUnsized`, create its
1965
+ // "unsized info", else just store None
1966
+ if Some ( trait_ref. def_id ) == tcx. lang_items ( ) . coerce_unsized_trait ( ) {
1967
+ let coerce_unsized_info = tcx. coerce_unsized_info ( def_id) ;
1968
+ record ! ( self . tables. coerce_unsized_info[ def_id] <- coerce_unsized_info) ;
1984
1969
}
1985
1970
}
1986
1971
}
0 commit comments