@@ -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 ;
@@ -1478,10 +1478,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
14781478 }
14791479 }
14801480
1481- let inherent_impls = tcx. with_stable_hashing_context ( |hcx| {
1482- tcx. crate_inherent_impls ( ( ) ) . unwrap ( ) . inherent_impls . to_sorted ( & hcx, true )
1483- } ) ;
1484- for ( def_id, impls) in inherent_impls {
1481+ for ( def_id, impls) in & tcx. crate_inherent_impls ( ( ) ) . unwrap ( ) . inherent_impls {
14851482 record_defaulted_array ! ( self . tables. inherent_impls[ def_id. to_def_id( ) ] <- impls. iter( ) . map( |def_id| {
14861483 assert!( def_id. is_local( ) ) ;
14871484 def_id. index
@@ -1952,8 +1949,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
19521949 fn encode_impls ( & mut self ) -> LazyArray < TraitImpls > {
19531950 empty_proc_macro ! ( self ) ;
19541951 let tcx = self . tcx ;
1955- let mut fx_hash_map : FxHashMap < DefId , Vec < ( DefIndex , Option < SimplifiedType > ) > > =
1956- FxHashMap :: default ( ) ;
1952+ let mut trait_impls : FxIndexMap < DefId , Vec < ( DefIndex , Option < SimplifiedType > ) > > =
1953+ FxIndexMap :: default ( ) ;
19571954
19581955 for id in tcx. hir ( ) . items ( ) {
19591956 let DefKind :: Impl { of_trait } = tcx. def_kind ( id. owner_id ) else {
@@ -1973,7 +1970,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
19731970 trait_ref. self_ty ( ) ,
19741971 TreatParams :: AsCandidateKey ,
19751972 ) ;
1976- fx_hash_map
1973+ trait_impls
19771974 . entry ( trait_ref. def_id )
19781975 . or_default ( )
19791976 . push ( ( id. owner_id . def_id . local_def_index , simplified_self_ty) ) ;
@@ -1994,47 +1991,30 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
19941991 }
19951992 }
19961993
1997- let mut all_impls: Vec < _ > = fx_hash_map. into_iter ( ) . collect ( ) ;
1998-
1999- // Bring everything into deterministic order for hashing
2000- all_impls. sort_by_cached_key ( |& ( trait_def_id, _) | tcx. def_path_hash ( trait_def_id) ) ;
2001-
2002- let all_impls: Vec < _ > = all_impls
1994+ let trait_impls: Vec < _ > = trait_impls
20031995 . into_iter ( )
2004- . map ( |( trait_def_id, mut impls) | {
2005- // Bring everything into deterministic order for hashing
2006- impls. sort_by_cached_key ( |& ( index, _) | {
2007- tcx. hir ( ) . def_path_hash ( LocalDefId { local_def_index : index } )
2008- } ) ;
2009-
2010- TraitImpls {
2011- trait_id : ( trait_def_id. krate . as_u32 ( ) , trait_def_id. index ) ,
2012- impls : self . lazy_array ( & impls) ,
2013- }
1996+ . map ( |( trait_def_id, impls) | TraitImpls {
1997+ trait_id : ( trait_def_id. krate . as_u32 ( ) , trait_def_id. index ) ,
1998+ impls : self . lazy_array ( & impls) ,
20141999 } )
20152000 . collect ( ) ;
20162001
2017- self . lazy_array ( & all_impls )
2002+ self . lazy_array ( & trait_impls )
20182003 }
20192004
20202005 #[ instrument( level = "debug" , skip( self ) ) ]
20212006 fn encode_incoherent_impls ( & mut self ) -> LazyArray < IncoherentImpls > {
20222007 empty_proc_macro ! ( self ) ;
20232008 let tcx = self . tcx ;
2024- let all_impls = tcx. with_stable_hashing_context ( |hcx| {
2025- tcx. crate_inherent_impls ( ( ) ) . unwrap ( ) . incoherent_impls . to_sorted ( & hcx, true )
2026- } ) ;
20272009
2028- let all_impls: Vec < _ > = all_impls
2029- . into_iter ( )
2030- . map ( |( & simp, impls) | {
2031- let mut impls: Vec < _ > =
2032- impls. into_iter ( ) . map ( |def_id| def_id. local_def_index ) . collect ( ) ;
2033- impls. sort_by_cached_key ( |& local_def_index| {
2034- tcx. hir ( ) . def_path_hash ( LocalDefId { local_def_index } )
2035- } ) ;
2036-
2037- IncoherentImpls { self_ty : simp, impls : self . lazy_array ( impls) }
2010+ let all_impls: Vec < _ > = tcx
2011+ . crate_inherent_impls ( ( ) )
2012+ . unwrap ( )
2013+ . incoherent_impls
2014+ . iter ( )
2015+ . map ( |( & simp, impls) | IncoherentImpls {
2016+ self_ty : simp,
2017+ impls : self . lazy_array ( impls. iter ( ) . map ( |def_id| def_id. local_def_index ) ) ,
20382018 } )
20392019 . collect ( ) ;
20402020
@@ -2278,6 +2258,8 @@ pub fn provide(providers: &mut Providers) {
22782258 span_bug ! ( tcx. def_span( def_id) , "no traits in scope for a doc link" )
22792259 } )
22802260 } ,
2261+
2262+ // TODO: Uplift these into
22812263 traits : |tcx, LocalCrate | {
22822264 let mut traits = Vec :: new ( ) ;
22832265 for id in tcx. hir ( ) . items ( ) {
@@ -2286,8 +2268,6 @@ pub fn provide(providers: &mut Providers) {
22862268 }
22872269 }
22882270
2289- // Bring everything into deterministic order.
2290- traits. sort_by_cached_key ( |& def_id| tcx. def_path_hash ( def_id) ) ;
22912271 tcx. arena . alloc_slice ( & traits)
22922272 } ,
22932273 trait_impls_in_crate : |tcx, LocalCrate | {
@@ -2300,8 +2280,6 @@ pub fn provide(providers: &mut Providers) {
23002280 }
23012281 }
23022282
2303- // Bring everything into deterministic order.
2304- trait_impls. sort_by_cached_key ( |& def_id| tcx. def_path_hash ( def_id) ) ;
23052283 tcx. arena . alloc_slice ( & trait_impls)
23062284 } ,
23072285
0 commit comments