From 6ffd654683900a81adda24b3a86e4c30fee31214 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Mon, 7 Mar 2022 13:31:49 +0000 Subject: [PATCH] Check that the cached stable hash is the right one if debug assertions are enabled --- compiler/rustc_data_structures/src/intern.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_data_structures/src/intern.rs b/compiler/rustc_data_structures/src/intern.rs index 1b187cd306e..bd62f30372e 100644 --- a/compiler/rustc_data_structures/src/intern.rs +++ b/compiler/rustc_data_structures/src/intern.rs @@ -160,9 +160,7 @@ impl Hash for InTy { impl, CTX: InternedHashingContext> HashStable for InTy { fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { - let stable_hash = self.stable_hash; - - if stable_hash == Fingerprint::ZERO { + if self.stable_hash == Fingerprint::ZERO || cfg!(debug_assertions) { // 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 // so rarely that the performance actually suffers. @@ -174,9 +172,15 @@ impl, CTX: InternedHashingContext> HashStable for InTy