@@ -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 ;
@@ -1491,10 +1491,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
14911491 }
14921492 }
14931493
1494- let inherent_impls = tcx. with_stable_hashing_context ( |hcx| {
1495- tcx. crate_inherent_impls ( ( ) ) . unwrap ( ) . inherent_impls . to_sorted ( & hcx, true )
1496- } ) ;
1497- for ( def_id, impls) in inherent_impls {
1494+ for ( def_id, impls) in & tcx. crate_inherent_impls ( ( ) ) . unwrap ( ) . inherent_impls {
14981495 record_defaulted_array ! ( self . tables. inherent_impls[ def_id. to_def_id( ) ] <- impls. iter( ) . map( |def_id| {
14991496 assert!( def_id. is_local( ) ) ;
15001497 def_id. index
@@ -1965,8 +1962,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
19651962 fn encode_impls ( & mut self ) -> LazyArray < TraitImpls > {
19661963 empty_proc_macro ! ( self ) ;
19671964 let tcx = self . tcx ;
1968- let mut fx_hash_map : FxHashMap < DefId , Vec < ( DefIndex , Option < SimplifiedType > ) > > =
1969- FxHashMap :: default ( ) ;
1965+ let mut trait_impls : FxIndexMap < DefId , Vec < ( DefIndex , Option < SimplifiedType > ) > > =
1966+ FxIndexMap :: default ( ) ;
19701967
19711968 for id in tcx. hir ( ) . items ( ) {
19721969 let DefKind :: Impl { of_trait } = tcx. def_kind ( id. owner_id ) else {
@@ -1986,7 +1983,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
19861983 trait_ref. self_ty ( ) ,
19871984 TreatParams :: AsCandidateKey ,
19881985 ) ;
1989- fx_hash_map
1986+ trait_impls
19901987 . entry ( trait_ref. def_id )
19911988 . or_default ( )
19921989 . push ( ( id. owner_id . def_id . local_def_index , simplified_self_ty) ) ;
@@ -2007,47 +2004,30 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
20072004 }
20082005 }
20092006
2010- let mut all_impls: Vec < _ > = fx_hash_map. into_iter ( ) . collect ( ) ;
2011-
2012- // Bring everything into deterministic order for hashing
2013- all_impls. sort_by_cached_key ( |& ( trait_def_id, _) | tcx. def_path_hash ( trait_def_id) ) ;
2014-
2015- let all_impls: Vec < _ > = all_impls
2007+ let trait_impls: Vec < _ > = trait_impls
20162008 . into_iter ( )
2017- . map ( |( trait_def_id, mut impls) | {
2018- // Bring everything into deterministic order for hashing
2019- impls. sort_by_cached_key ( |& ( index, _) | {
2020- tcx. hir ( ) . def_path_hash ( LocalDefId { local_def_index : index } )
2021- } ) ;
2022-
2023- TraitImpls {
2024- trait_id : ( trait_def_id. krate . as_u32 ( ) , trait_def_id. index ) ,
2025- impls : self . lazy_array ( & impls) ,
2026- }
2009+ . map ( |( trait_def_id, impls) | TraitImpls {
2010+ trait_id : ( trait_def_id. krate . as_u32 ( ) , trait_def_id. index ) ,
2011+ impls : self . lazy_array ( & impls) ,
20272012 } )
20282013 . collect ( ) ;
20292014
2030- self . lazy_array ( & all_impls )
2015+ self . lazy_array ( & trait_impls )
20312016 }
20322017
20332018 #[ instrument( level = "debug" , skip( self ) ) ]
20342019 fn encode_incoherent_impls ( & mut self ) -> LazyArray < IncoherentImpls > {
20352020 empty_proc_macro ! ( self ) ;
20362021 let tcx = self . tcx ;
2037- let all_impls = tcx. with_stable_hashing_context ( |hcx| {
2038- tcx. crate_inherent_impls ( ( ) ) . unwrap ( ) . incoherent_impls . to_sorted ( & hcx, true )
2039- } ) ;
20402022
2041- let all_impls: Vec < _ > = all_impls
2042- . into_iter ( )
2043- . map ( |( & simp, impls) | {
2044- let mut impls: Vec < _ > =
2045- impls. into_iter ( ) . map ( |def_id| def_id. local_def_index ) . collect ( ) ;
2046- impls. sort_by_cached_key ( |& local_def_index| {
2047- tcx. hir ( ) . def_path_hash ( LocalDefId { local_def_index } )
2048- } ) ;
2049-
2050- IncoherentImpls { self_ty : simp, impls : self . lazy_array ( impls) }
2023+ let all_impls: Vec < _ > = tcx
2024+ . crate_inherent_impls ( ( ) )
2025+ . unwrap ( )
2026+ . incoherent_impls
2027+ . iter ( )
2028+ . map ( |( & simp, impls) | IncoherentImpls {
2029+ self_ty : simp,
2030+ impls : self . lazy_array ( impls. iter ( ) . map ( |def_id| def_id. local_def_index ) ) ,
20512031 } )
20522032 . collect ( ) ;
20532033
@@ -2291,6 +2271,8 @@ pub fn provide(providers: &mut Providers) {
22912271 span_bug ! ( tcx. def_span( def_id) , "no traits in scope for a doc link" )
22922272 } )
22932273 } ,
2274+
2275+ // TODO: Uplift these into
22942276 traits : |tcx, LocalCrate | {
22952277 let mut traits = Vec :: new ( ) ;
22962278 for id in tcx. hir ( ) . items ( ) {
@@ -2299,8 +2281,6 @@ pub fn provide(providers: &mut Providers) {
22992281 }
23002282 }
23012283
2302- // Bring everything into deterministic order.
2303- traits. sort_by_cached_key ( |& def_id| tcx. def_path_hash ( def_id) ) ;
23042284 tcx. arena . alloc_slice ( & traits)
23052285 } ,
23062286 trait_impls_in_crate : |tcx, LocalCrate | {
@@ -2313,8 +2293,6 @@ pub fn provide(providers: &mut Providers) {
23132293 }
23142294 }
23152295
2316- // Bring everything into deterministic order.
2317- trait_impls. sort_by_cached_key ( |& def_id| tcx. def_path_hash ( def_id) ) ;
23182296 tcx. arena . alloc_slice ( & trait_impls)
23192297 } ,
23202298
0 commit comments