]> git.lizzy.rs Git - rust.git/commitdiff
Make TypeIdHasher use DefPath::deterministic_hash() for stability.
authorMichael Woerister <michaelwoerister@posteo.net>
Tue, 13 Sep 2016 12:45:34 +0000 (08:45 -0400)
committerMichael Woerister <michaelwoerister@posteo.net>
Tue, 13 Sep 2016 19:22:51 +0000 (15:22 -0400)
src/librustc/ty/util.rs

index c6020838b5320e9f4d94aebdbc35f6b48d0b6150..a8287ecc046cfb703612d28b082e4e100058b2ed 100644 (file)
@@ -411,15 +411,11 @@ fn hash_discriminant_u8<T>(&mut self, x: &T) {
     }
 
     fn def_id(&mut self, did: DefId) {
-        // Hash the crate identification information.
-        let name = self.tcx.crate_name(did.krate);
-        let disambiguator = self.tcx.crate_disambiguator(did.krate);
-        self.hash((name, disambiguator));
-
-        // Hash the item path within that crate.
-        // FIXME(#35379) This should use a deterministic
-        // DefPath hashing mechanism, not the DefIndex.
-        self.hash(did.index);
+        // Hash the DefPath corresponding to the DefId, which is independent
+        // of compiler internal state.
+        let tcx = self.tcx;
+        let def_path = tcx.def_path(did);
+        def_path.deterministic_hash_to(tcx, &mut self.state);
     }
 }