File tree 1 file changed +8
-4
lines changed
compiler/rustc_data_structures/src
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> {
160
160
161
161
impl < T : HashStable < CTX > , CTX : InternedHashingContext > HashStable < CTX > for InTy < T > {
162
162
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) {
166
164
// No cached hash available. This can only mean that incremental is disabled.
167
165
// We don't cache stable hashes in non-incremental mode, because they are used
168
166
// so rarely that the performance actually suffers.
@@ -174,9 +172,15 @@ impl<T: HashStable<CTX>, CTX: InternedHashingContext> HashStable<CTX> for InTy<T
174
172
hcx. with_def_path_and_no_spans ( |hcx| self . internee . hash_stable ( hcx, & mut hasher) ) ;
175
173
hasher. finish ( )
176
174
} ;
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
+ }
177
181
stable_hash. hash_stable ( hcx, hasher) ;
178
182
} else {
179
- stable_hash. hash_stable ( hcx, hasher) ;
183
+ self . stable_hash . hash_stable ( hcx, hasher) ;
180
184
}
181
185
}
182
186
}
You can’t perform that action at this time.
0 commit comments