about summary refs log tree commit diff
path: root/compiler/rustc_query_system
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-04-09 02:31:24 +0000
committerbors <bors@rust-lang.org>2022-04-09 02:31:24 +0000
commite980c6295582792e4a7c2d67e33cece60c170115 (patch)
tree0e52df53a2dba63646376b4f633f595652d05bd4 /compiler/rustc_query_system
parent340f6491bed3525acfabbdbd1545b6aee2fca62b (diff)
parent25d6f8e0f647f865775158f35408724278145c50 (diff)
downloadrust-e980c6295582792e4a7c2d67e33cece60c170115.tar.gz
rust-e980c6295582792e4a7c2d67e33cece60c170115.zip
Auto merge of #95524 - oli-obk:cached_stable_hash_cleanups, r=nnethercote
Cached stable hash cleanups

r? `@nnethercote`

Add a sanity assertion in debug mode to check that the cached hashes are actually the ones we get if we compute the hash each time.

Add a new data structure that bundles all the hash-caching work to make it easier to re-use it for different interned data structures
Diffstat (limited to 'compiler/rustc_query_system')
-rw-r--r--compiler/rustc_query_system/src/ich/hcx.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/rustc_query_system/src/ich/hcx.rs b/compiler/rustc_query_system/src/ich/hcx.rs
index 76e21be17bc..a073bf71057 100644
--- a/compiler/rustc_query_system/src/ich/hcx.rs
+++ b/compiler/rustc_query_system/src/ich/hcx.rs
@@ -231,4 +231,12 @@ impl<'a> rustc_span::HashStableContext for StableHashingContext<'a> {
     }
 }
 
+impl<'a> rustc_data_structures::intern::InternedHashingContext for StableHashingContext<'a> {
+    fn with_def_path_and_no_spans(&mut self, f: impl FnOnce(&mut Self)) {
+        self.while_hashing_spans(false, |hcx| {
+            hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| f(hcx))
+        });
+    }
+}
+
 impl<'a> rustc_session::HashStableContext for StableHashingContext<'a> {}