@@ -2,7 +2,7 @@ use crate::errors::{FailCreateFileEncoder, FailWriteFile};
2
2
use crate :: rmeta:: * ;
3
3
4
4
use rustc_ast:: Attribute ;
5
- use rustc_data_structures:: fx:: FxIndexSet ;
5
+ use rustc_data_structures:: fx:: { FxIndexMap , FxIndexSet } ;
6
6
use rustc_data_structures:: memmap:: { Mmap , MmapMut } ;
7
7
use rustc_data_structures:: sync:: { join, par_for_each_in, Lrc } ;
8
8
use rustc_data_structures:: temp_dir:: MaybeTempDir ;
@@ -1491,10 +1491,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1491
1491
}
1492
1492
}
1493
1493
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 {
1498
1495
record_defaulted_array ! ( self . tables. inherent_impls[ def_id. to_def_id( ) ] <- impls. iter( ) . map( |def_id| {
1499
1496
assert!( def_id. is_local( ) ) ;
1500
1497
def_id. index
@@ -1965,8 +1962,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1965
1962
fn encode_impls ( & mut self ) -> LazyArray < TraitImpls > {
1966
1963
empty_proc_macro ! ( self ) ;
1967
1964
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 ( ) ;
1970
1967
1971
1968
for id in tcx. hir ( ) . items ( ) {
1972
1969
let DefKind :: Impl { of_trait } = tcx. def_kind ( id. owner_id ) else {
@@ -1986,7 +1983,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1986
1983
trait_ref. self_ty ( ) ,
1987
1984
TreatParams :: AsCandidateKey ,
1988
1985
) ;
1989
- fx_hash_map
1986
+ trait_impls
1990
1987
. entry ( trait_ref. def_id )
1991
1988
. or_default ( )
1992
1989
. push ( ( id. owner_id . def_id . local_def_index , simplified_self_ty) ) ;
@@ -2007,47 +2004,30 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
2007
2004
}
2008
2005
}
2009
2006
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
2016
2008
. 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) ,
2027
2012
} )
2028
2013
. collect ( ) ;
2029
2014
2030
- self . lazy_array ( & all_impls )
2015
+ self . lazy_array ( & trait_impls )
2031
2016
}
2032
2017
2033
2018
#[ instrument( level = "debug" , skip( self ) ) ]
2034
2019
fn encode_incoherent_impls ( & mut self ) -> LazyArray < IncoherentImpls > {
2035
2020
empty_proc_macro ! ( self ) ;
2036
2021
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
- } ) ;
2040
2022
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 ) ) ,
2051
2031
} )
2052
2032
. collect ( ) ;
2053
2033
@@ -2291,6 +2271,8 @@ pub fn provide(providers: &mut Providers) {
2291
2271
span_bug ! ( tcx. def_span( def_id) , "no traits in scope for a doc link" )
2292
2272
} )
2293
2273
} ,
2274
+
2275
+ // TODO: Uplift these into
2294
2276
traits : |tcx, LocalCrate | {
2295
2277
let mut traits = Vec :: new ( ) ;
2296
2278
for id in tcx. hir ( ) . items ( ) {
@@ -2299,8 +2281,6 @@ pub fn provide(providers: &mut Providers) {
2299
2281
}
2300
2282
}
2301
2283
2302
- // Bring everything into deterministic order.
2303
- traits. sort_by_cached_key ( |& def_id| tcx. def_path_hash ( def_id) ) ;
2304
2284
tcx. arena . alloc_slice ( & traits)
2305
2285
} ,
2306
2286
trait_impls_in_crate : |tcx, LocalCrate | {
@@ -2313,8 +2293,6 @@ pub fn provide(providers: &mut Providers) {
2313
2293
}
2314
2294
}
2315
2295
2316
- // Bring everything into deterministic order.
2317
- trait_impls. sort_by_cached_key ( |& def_id| tcx. def_path_hash ( def_id) ) ;
2318
2296
tcx. arena . alloc_slice ( & trait_impls)
2319
2297
} ,
2320
2298
0 commit comments