@@ -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 ;
@@ -1478,10 +1478,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1478
1478
}
1479
1479
}
1480
1480
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 {
1485
1482
record_defaulted_array ! ( self . tables. inherent_impls[ def_id. to_def_id( ) ] <- impls. iter( ) . map( |def_id| {
1486
1483
assert!( def_id. is_local( ) ) ;
1487
1484
def_id. index
@@ -1952,8 +1949,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1952
1949
fn encode_impls ( & mut self ) -> LazyArray < TraitImpls > {
1953
1950
empty_proc_macro ! ( self ) ;
1954
1951
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 ( ) ;
1957
1954
1958
1955
for id in tcx. hir ( ) . items ( ) {
1959
1956
let DefKind :: Impl { of_trait } = tcx. def_kind ( id. owner_id ) else {
@@ -1973,7 +1970,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1973
1970
trait_ref. self_ty ( ) ,
1974
1971
TreatParams :: AsCandidateKey ,
1975
1972
) ;
1976
- fx_hash_map
1973
+ trait_impls
1977
1974
. entry ( trait_ref. def_id )
1978
1975
. or_default ( )
1979
1976
. push ( ( id. owner_id . def_id . local_def_index , simplified_self_ty) ) ;
@@ -1994,47 +1991,30 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1994
1991
}
1995
1992
}
1996
1993
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
2003
1995
. 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) ,
2014
1999
} )
2015
2000
. collect ( ) ;
2016
2001
2017
- self . lazy_array ( & all_impls )
2002
+ self . lazy_array ( & trait_impls )
2018
2003
}
2019
2004
2020
2005
#[ instrument( level = "debug" , skip( self ) ) ]
2021
2006
fn encode_incoherent_impls ( & mut self ) -> LazyArray < IncoherentImpls > {
2022
2007
empty_proc_macro ! ( self ) ;
2023
2008
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
- } ) ;
2027
2009
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 ) ) ,
2038
2018
} )
2039
2019
. collect ( ) ;
2040
2020
@@ -2278,6 +2258,8 @@ pub fn provide(providers: &mut Providers) {
2278
2258
span_bug ! ( tcx. def_span( def_id) , "no traits in scope for a doc link" )
2279
2259
} )
2280
2260
} ,
2261
+
2262
+ // TODO: Uplift these into
2281
2263
traits : |tcx, LocalCrate | {
2282
2264
let mut traits = Vec :: new ( ) ;
2283
2265
for id in tcx. hir ( ) . items ( ) {
@@ -2286,8 +2268,6 @@ pub fn provide(providers: &mut Providers) {
2286
2268
}
2287
2269
}
2288
2270
2289
- // Bring everything into deterministic order.
2290
- traits. sort_by_cached_key ( |& def_id| tcx. def_path_hash ( def_id) ) ;
2291
2271
tcx. arena . alloc_slice ( & traits)
2292
2272
} ,
2293
2273
trait_impls_in_crate : |tcx, LocalCrate | {
@@ -2300,8 +2280,6 @@ pub fn provide(providers: &mut Providers) {
2300
2280
}
2301
2281
}
2302
2282
2303
- // Bring everything into deterministic order.
2304
- trait_impls. sort_by_cached_key ( |& def_id| tcx. def_path_hash ( def_id) ) ;
2305
2283
tcx. arena . alloc_slice ( & trait_impls)
2306
2284
} ,
2307
2285
0 commit comments