Skip to content

Commit 75a0dd0

Browse files
Make TypeIdHasher use DefPath::deterministic_hash() for stability.
1 parent 94d7501 commit 75a0dd0

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/librustc/ty/util.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -411,15 +411,11 @@ impl<'a, 'gcx, 'tcx> TypeIdHasher<'a, 'gcx, 'tcx> {
411411
}
412412

413413
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);
423419
}
424420
}
425421

0 commit comments

Comments
 (0)