@@ -411,15 +411,11 @@ impl<'a, 'gcx, 'tcx> TypeIdHasher<'a, 'gcx, 'tcx> {
411
411
}
412
412
413
413
fn def_id ( & mut self , did : DefId ) {
414
- // Hash the crate identification information.
415
- let name = self . tcx . crate_name ( did. krate ) ;
416
- let disambiguator = self . tcx . crate_disambiguator ( did. krate ) ;
417
- self . hash ( ( name, disambiguator) ) ;
418
-
419
- // Hash the item path within that crate.
420
- // FIXME(#35379) This should use a deterministic
421
- // DefPath hashing mechanism, not the DefIndex.
422
- self . hash ( did. index ) ;
414
+ // Hash the DefPath corresponding to the DefId, which is independent
415
+ // of compiler internal state.
416
+ let tcx = self . tcx ;
417
+ let def_path = tcx. def_path ( did) ;
418
+ def_path. deterministic_hash_to ( tcx, & mut self . state ) ;
423
419
}
424
420
}
425
421
@@ -445,33 +441,8 @@ impl<'a, 'gcx, 'tcx> TypeVisitor<'tcx> for TypeIdHasher<'a, 'gcx, 'tcx> {
445
441
self . hash ( f. sig . variadic ( ) ) ;
446
442
}
447
443
TyTrait ( ref data) => {
448
- // Trait objects have a list of projection bounds
449
- // that are not guaranteed to be sorted in an order
450
- // that gets preserved across crates, so we need
451
- // to sort them again by the name, in string form.
452
-
453
- // Hash the whole principal trait ref.
454
444
self . def_id ( data. principal . def_id ( ) ) ;
455
- data. principal . visit_with ( self ) ;
456
-
457
- // Hash region and builtin bounds.
458
- data. region_bound . visit_with ( self ) ;
459
445
self . hash ( data. builtin_bounds ) ;
460
-
461
- // Only projection bounds are left, sort and hash them.
462
- let mut projection_bounds: Vec < _ > = data. projection_bounds
463
- . iter ( )
464
- . map ( |b| ( b. item_name ( ) . as_str ( ) , b) )
465
- . collect ( ) ;
466
- projection_bounds. sort_by_key ( |& ( ref name, _) | name. clone ( ) ) ;
467
- for ( name, bound) in projection_bounds {
468
- self . def_id ( bound. 0 . trait_ref . def_id ) ;
469
- self . hash ( name) ;
470
- bound. visit_with ( self ) ;
471
- }
472
-
473
- // Bypass super_visit_with, we've visited everything.
474
- return false ;
475
446
}
476
447
TyTuple ( tys) => {
477
448
self . hash ( tys. len ( ) ) ;
0 commit comments