@@ -943,7 +943,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
943
943
let trait_ref = tcx. impl_trait_ref ( def_id) ;
944
944
let parent = if let Some ( trait_ref) = trait_ref {
945
945
let trait_def = tcx. trait_def ( trait_ref. def_id ) ;
946
- trait_def. ancestors ( def_id) . skip ( 1 ) . next ( ) . and_then ( |node| {
946
+ trait_def. ancestors ( tcx , def_id) . skip ( 1 ) . next ( ) . and_then ( |node| {
947
947
match node {
948
948
specialization_graph:: Node :: Impl ( parent) => Some ( parent) ,
949
949
_ => None ,
@@ -1295,23 +1295,37 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
1295
1295
1296
1296
/// Encodes an index, mapping each trait to its (local) implementations.
1297
1297
fn encode_impls ( & mut self , _: ( ) ) -> LazySeq < TraitImpls > {
1298
+ debug ! ( "IsolatedEncoder::encode_impls()" ) ;
1299
+ let tcx = self . tcx ;
1298
1300
let mut visitor = ImplVisitor {
1299
- tcx : self . tcx ,
1301
+ tcx : tcx,
1300
1302
impls : FxHashMap ( ) ,
1301
1303
} ;
1302
- self . tcx . hir . krate ( ) . visit_all_item_likes ( & mut visitor) ;
1304
+ tcx. hir . krate ( ) . visit_all_item_likes ( & mut visitor) ;
1305
+
1306
+ let mut all_impls: Vec < _ > = visitor. impls . into_iter ( ) . collect ( ) ;
1303
1307
1304
- let all_impls: Vec < _ > = visitor. impls
1308
+ // Bring everything into deterministic order for hashing
1309
+ all_impls. sort_unstable_by_key ( |& ( trait_def_id, _) | {
1310
+ tcx. def_path_hash ( trait_def_id)
1311
+ } ) ;
1312
+
1313
+ let all_impls: Vec < _ > = all_impls
1305
1314
. into_iter ( )
1306
- . map ( |( trait_def_id, impls) | {
1315
+ . map ( |( trait_def_id, mut impls) | {
1316
+ // Bring everything into deterministic order for hashing
1317
+ impls. sort_unstable_by_key ( |& def_index| {
1318
+ tcx. hir . definitions ( ) . def_path_hash ( def_index)
1319
+ } ) ;
1320
+
1307
1321
TraitImpls {
1308
1322
trait_id : ( trait_def_id. krate . as_u32 ( ) , trait_def_id. index ) ,
1309
- impls : self . lazy_seq ( impls) ,
1323
+ impls : self . lazy_seq_from_slice ( & impls[ .. ] ) ,
1310
1324
}
1311
1325
} )
1312
1326
. collect ( ) ;
1313
1327
1314
- self . lazy_seq ( all_impls)
1328
+ self . lazy_seq_from_slice ( & all_impls[ .. ] )
1315
1329
}
1316
1330
1317
1331
// Encodes all symbols exported from this crate into the metadata.
0 commit comments