@@ -2,7 +2,7 @@ use crate::errors::{FailCreateFileEncoder, FailWriteFile};
22use crate :: rmeta:: * ;
33
44use rustc_ast:: Attribute ;
5- use rustc_data_structures:: fx:: FxIndexSet ;
5+ use rustc_data_structures:: fx:: { FxIndexMap , FxIndexSet } ;
66use rustc_data_structures:: memmap:: { Mmap , MmapMut } ;
77use rustc_data_structures:: sync:: { join, par_for_each_in, Lrc } ;
88use rustc_data_structures:: temp_dir:: MaybeTempDir ;
@@ -1508,10 +1508,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
15081508 }
15091509 }
15101510
1511- let inherent_impls = tcx. with_stable_hashing_context ( |hcx| {
1512- tcx. crate_inherent_impls ( ( ) ) . unwrap ( ) . inherent_impls . to_sorted ( & hcx, true )
1513- } ) ;
1514- for ( def_id, impls) in inherent_impls {
1511+ for ( def_id, impls) in & tcx. crate_inherent_impls ( ( ) ) . unwrap ( ) . inherent_impls {
15151512 record_defaulted_array ! ( self . tables. inherent_impls[ def_id. to_def_id( ) ] <- impls. iter( ) . map( |def_id| {
15161513 assert!( def_id. is_local( ) ) ;
15171514 def_id. index
@@ -1992,8 +1989,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
19921989 fn encode_impls ( & mut self ) -> LazyArray < TraitImpls > {
19931990 empty_proc_macro ! ( self ) ;
19941991 let tcx = self . tcx ;
1995- let mut fx_hash_map : FxHashMap < DefId , Vec < ( DefIndex , Option < SimplifiedType > ) > > =
1996- FxHashMap :: default ( ) ;
1992+ let mut trait_impls : FxIndexMap < DefId , Vec < ( DefIndex , Option < SimplifiedType > ) > > =
1993+ FxIndexMap :: default ( ) ;
19971994
19981995 for id in tcx. hir ( ) . items ( ) {
19991996 let DefKind :: Impl { of_trait } = tcx. def_kind ( id. owner_id ) else {
@@ -2012,7 +2009,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
20122009 trait_ref. self_ty ( ) ,
20132010 TreatParams :: AsCandidateKey ,
20142011 ) ;
2015- fx_hash_map
2012+ trait_impls
20162013 . entry ( trait_ref. def_id )
20172014 . or_default ( )
20182015 . push ( ( id. owner_id . def_id . local_def_index , simplified_self_ty) ) ;
@@ -2033,47 +2030,30 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
20332030 }
20342031 }
20352032
2036- let mut all_impls: Vec < _ > = fx_hash_map. into_iter ( ) . collect ( ) ;
2037-
2038- // Bring everything into deterministic order for hashing
2039- all_impls. sort_by_cached_key ( |& ( trait_def_id, _) | tcx. def_path_hash ( trait_def_id) ) ;
2040-
2041- let all_impls: Vec < _ > = all_impls
2033+ let trait_impls: Vec < _ > = trait_impls
20422034 . into_iter ( )
2043- . map ( |( trait_def_id, mut impls) | {
2044- // Bring everything into deterministic order for hashing
2045- impls. sort_by_cached_key ( |& ( index, _) | {
2046- tcx. hir ( ) . def_path_hash ( LocalDefId { local_def_index : index } )
2047- } ) ;
2048-
2049- TraitImpls {
2050- trait_id : ( trait_def_id. krate . as_u32 ( ) , trait_def_id. index ) ,
2051- impls : self . lazy_array ( & impls) ,
2052- }
2035+ . map ( |( trait_def_id, impls) | TraitImpls {
2036+ trait_id : ( trait_def_id. krate . as_u32 ( ) , trait_def_id. index ) ,
2037+ impls : self . lazy_array ( & impls) ,
20532038 } )
20542039 . collect ( ) ;
20552040
2056- self . lazy_array ( & all_impls )
2041+ self . lazy_array ( & trait_impls )
20572042 }
20582043
20592044 #[ instrument( level = "debug" , skip( self ) ) ]
20602045 fn encode_incoherent_impls ( & mut self ) -> LazyArray < IncoherentImpls > {
20612046 empty_proc_macro ! ( self ) ;
20622047 let tcx = self . tcx ;
2063- let all_impls = tcx. with_stable_hashing_context ( |hcx| {
2064- tcx. crate_inherent_impls ( ( ) ) . unwrap ( ) . incoherent_impls . to_sorted ( & hcx, true )
2065- } ) ;
20662048
2067- let all_impls: Vec < _ > = all_impls
2068- . into_iter ( )
2069- . map ( |( & simp, impls) | {
2070- let mut impls: Vec < _ > =
2071- impls. into_iter ( ) . map ( |def_id| def_id. local_def_index ) . collect ( ) ;
2072- impls. sort_by_cached_key ( |& local_def_index| {
2073- tcx. hir ( ) . def_path_hash ( LocalDefId { local_def_index } )
2074- } ) ;
2075-
2076- IncoherentImpls { self_ty : simp, impls : self . lazy_array ( impls) }
2049+ let all_impls: Vec < _ > = tcx
2050+ . crate_inherent_impls ( ( ) )
2051+ . unwrap ( )
2052+ . incoherent_impls
2053+ . iter ( )
2054+ . map ( |( & simp, impls) | IncoherentImpls {
2055+ self_ty : simp,
2056+ impls : self . lazy_array ( impls. iter ( ) . map ( |def_id| def_id. local_def_index ) ) ,
20772057 } )
20782058 . collect ( ) ;
20792059
@@ -2317,6 +2297,8 @@ pub fn provide(providers: &mut Providers) {
23172297 span_bug ! ( tcx. def_span( def_id) , "no traits in scope for a doc link" )
23182298 } )
23192299 } ,
2300+
2301+ // TODO: Uplift these into
23202302 traits : |tcx, LocalCrate | {
23212303 let mut traits = Vec :: new ( ) ;
23222304 for id in tcx. hir ( ) . items ( ) {
@@ -2325,8 +2307,6 @@ pub fn provide(providers: &mut Providers) {
23252307 }
23262308 }
23272309
2328- // Bring everything into deterministic order.
2329- traits. sort_by_cached_key ( |& def_id| tcx. def_path_hash ( def_id) ) ;
23302310 tcx. arena . alloc_slice ( & traits)
23312311 } ,
23322312 trait_impls_in_crate : |tcx, LocalCrate | {
@@ -2339,8 +2319,6 @@ pub fn provide(providers: &mut Providers) {
23392319 }
23402320 }
23412321
2342- // Bring everything into deterministic order.
2343- trait_impls. sort_by_cached_key ( |& def_id| tcx. def_path_hash ( def_id) ) ;
23442322 tcx. arena . alloc_slice ( & trait_impls)
23452323 } ,
23462324
0 commit comments