Check that the cached stable hash is the right one if debug assertions are enabled
This commit is contained in:
parent
33d0ce95a9
commit
6ffd654683
1 changed files with 8 additions and 4 deletions
|
@ -160,9 +160,7 @@ impl<T: Hash> Hash for InTy<T> {
|
||||||
|
|
||||||
impl<T: HashStable<CTX>, CTX: InternedHashingContext> HashStable<CTX> for InTy<T> {
|
impl<T: HashStable<CTX>, CTX: InternedHashingContext> HashStable<CTX> for InTy<T> {
|
||||||
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
|
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
|
||||||
let stable_hash = self.stable_hash;
|
if self.stable_hash == Fingerprint::ZERO || cfg!(debug_assertions) {
|
||||||
|
|
||||||
if stable_hash == Fingerprint::ZERO {
|
|
||||||
// No cached hash available. This can only mean that incremental is disabled.
|
// No cached hash available. This can only mean that incremental is disabled.
|
||||||
// We don't cache stable hashes in non-incremental mode, because they are used
|
// We don't cache stable hashes in non-incremental mode, because they are used
|
||||||
// so rarely that the performance actually suffers.
|
// so rarely that the performance actually suffers.
|
||||||
|
@ -174,9 +172,15 @@ impl<T: HashStable<CTX>, CTX: InternedHashingContext> HashStable<CTX> for InTy<T
|
||||||
hcx.with_def_path_and_no_spans(|hcx| self.internee.hash_stable(hcx, &mut hasher));
|
hcx.with_def_path_and_no_spans(|hcx| self.internee.hash_stable(hcx, &mut hasher));
|
||||||
hasher.finish()
|
hasher.finish()
|
||||||
};
|
};
|
||||||
|
if cfg!(debug_assertions) && self.stable_hash != Fingerprint::ZERO {
|
||||||
|
assert_eq!(
|
||||||
|
stable_hash, self.stable_hash,
|
||||||
|
"cached stable hash does not match freshly computed stable hash"
|
||||||
|
);
|
||||||
|
}
|
||||||
stable_hash.hash_stable(hcx, hasher);
|
stable_hash.hash_stable(hcx, hasher);
|
||||||
} else {
|
} else {
|
||||||
stable_hash.hash_stable(hcx, hasher);
|
self.stable_hash.hash_stable(hcx, hasher);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue