This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
compiler/rustc_data_structures/src Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -160,9 +160,7 @@ impl<T: Hash> Hash for InTy<T> {
160160
161161impl < T : HashStable < CTX > , CTX : InternedHashingContext > HashStable < CTX > for InTy < T > {
162162 fn hash_stable ( & self , hcx : & mut CTX , hasher : & mut StableHasher ) {
163- let stable_hash = self . stable_hash ;
164-
165- if stable_hash == Fingerprint :: ZERO {
163+ if self . stable_hash == Fingerprint :: ZERO || cfg ! ( debug_assertions) {
166164 // No cached hash available. This can only mean that incremental is disabled.
167165 // We don't cache stable hashes in non-incremental mode, because they are used
168166 // so rarely that the performance actually suffers.
@@ -174,9 +172,15 @@ impl<T: HashStable<CTX>, CTX: InternedHashingContext> HashStable<CTX> for InTy<T
174172 hcx. with_def_path_and_no_spans ( |hcx| self . internee . hash_stable ( hcx, & mut hasher) ) ;
175173 hasher. finish ( )
176174 } ;
175+ if cfg ! ( debug_assertions) && self . stable_hash != Fingerprint :: ZERO {
176+ assert_eq ! (
177+ stable_hash, self . stable_hash,
178+ "cached stable hash does not match freshly computed stable hash"
179+ ) ;
180+ }
177181 stable_hash. hash_stable ( hcx, hasher) ;
178182 } else {
179- stable_hash. hash_stable ( hcx, hasher) ;
183+ self . stable_hash . hash_stable ( hcx, hasher) ;
180184 }
181185 }
182186}
You can’t perform that action at this time.
0 commit comments