@@ -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 ;
@@ -1508,10 +1508,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1508
1508
}
1509
1509
}
1510
1510
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 {
1515
1512
record_defaulted_array ! ( self . tables. inherent_impls[ def_id. to_def_id( ) ] <- impls. iter( ) . map( |def_id| {
1516
1513
assert!( def_id. is_local( ) ) ;
1517
1514
def_id. index
@@ -1992,8 +1989,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1992
1989
fn encode_impls ( & mut self ) -> LazyArray < TraitImpls > {
1993
1990
empty_proc_macro ! ( self ) ;
1994
1991
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 ( ) ;
1997
1994
1998
1995
for id in tcx. hir ( ) . items ( ) {
1999
1996
let DefKind :: Impl { of_trait } = tcx. def_kind ( id. owner_id ) else {
@@ -2012,7 +2009,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
2012
2009
trait_ref. self_ty ( ) ,
2013
2010
TreatParams :: AsCandidateKey ,
2014
2011
) ;
2015
- fx_hash_map
2012
+ trait_impls
2016
2013
. entry ( trait_ref. def_id )
2017
2014
. or_default ( )
2018
2015
. push ( ( id. owner_id . def_id . local_def_index , simplified_self_ty) ) ;
@@ -2033,47 +2030,30 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
2033
2030
}
2034
2031
}
2035
2032
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
2042
2034
. 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) ,
2053
2038
} )
2054
2039
. collect ( ) ;
2055
2040
2056
- self . lazy_array ( & all_impls )
2041
+ self . lazy_array ( & trait_impls )
2057
2042
}
2058
2043
2059
2044
#[ instrument( level = "debug" , skip( self ) ) ]
2060
2045
fn encode_incoherent_impls ( & mut self ) -> LazyArray < IncoherentImpls > {
2061
2046
empty_proc_macro ! ( self ) ;
2062
2047
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
- } ) ;
2066
2048
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 ) ) ,
2077
2057
} )
2078
2058
. collect ( ) ;
2079
2059
@@ -2317,6 +2297,8 @@ pub fn provide(providers: &mut Providers) {
2317
2297
span_bug ! ( tcx. def_span( def_id) , "no traits in scope for a doc link" )
2318
2298
} )
2319
2299
} ,
2300
+
2301
+ // TODO: Uplift these into
2320
2302
traits : |tcx, LocalCrate | {
2321
2303
let mut traits = Vec :: new ( ) ;
2322
2304
for id in tcx. hir ( ) . items ( ) {
@@ -2325,8 +2307,6 @@ pub fn provide(providers: &mut Providers) {
2325
2307
}
2326
2308
}
2327
2309
2328
- // Bring everything into deterministic order.
2329
- traits. sort_by_cached_key ( |& def_id| tcx. def_path_hash ( def_id) ) ;
2330
2310
tcx. arena . alloc_slice ( & traits)
2331
2311
} ,
2332
2312
trait_impls_in_crate : |tcx, LocalCrate | {
@@ -2339,8 +2319,6 @@ pub fn provide(providers: &mut Providers) {
2339
2319
}
2340
2320
}
2341
2321
2342
- // Bring everything into deterministic order.
2343
- trait_impls. sort_by_cached_key ( |& def_id| tcx. def_path_hash ( def_id) ) ;
2344
2322
tcx. arena . alloc_slice ( & trait_impls)
2345
2323
} ,
2346
2324
0 commit comments