about summary refs log tree commit diff
path: root/compiler/rustc_query_system/src
diff options
context:
space:
mode:
authorCamille GILLOT <gillot.camille@gmail.com>2023-03-07 08:34:47 +0000
committerCamille GILLOT <gillot.camille@gmail.com>2023-03-11 22:41:01 +0000
commit382cc909d5d9a4b06e1aaec0178b64e05730614a (patch)
tree5f8ddce3c5c7cd134ce5f55d74f9d25576aba0ff /compiler/rustc_query_system/src
parentfacf1e017d2372364aafc6289278117281bb0d1f (diff)
downloadrust-382cc909d5d9a4b06e1aaec0178b64e05730614a.tar.gz
rust-382cc909d5d9a4b06e1aaec0178b64e05730614a.zip
Make the check for cache opt-in.
Diffstat (limited to 'compiler/rustc_query_system/src')
-rw-r--r--compiler/rustc_query_system/src/query/plumbing.rs12
1 files changed, 9 insertions, 3 deletions
diff --git a/compiler/rustc_query_system/src/query/plumbing.rs b/compiler/rustc_query_system/src/query/plumbing.rs
index 1229a5fe5e8..04ab2b767e2 100644
--- a/compiler/rustc_query_system/src/query/plumbing.rs
+++ b/compiler/rustc_query_system/src/query/plumbing.rs
@@ -711,6 +711,7 @@ fn ensure_must_run<Q, Qcx>(
     query: Q,
     qcx: Qcx,
     key: &Q::Key,
+    check_cache: bool,
 ) -> (bool, Option<DepNode<Qcx::DepKind>>)
 where
     Q: QueryConfig<Qcx>,
@@ -743,6 +744,11 @@ where
         }
     };
 
+    // We do not need the value at all, so do not check the cache.
+    if !check_cache {
+        return (false, None);
+    }
+
     let loadable = query.loadable_from_disk(qcx, key, serialized_dep_node_index);
     (!loadable, Some(dep_node))
 }
@@ -750,7 +756,7 @@ where
 #[derive(Debug)]
 pub enum QueryMode {
     Get,
-    Ensure,
+    Ensure { check_cache: bool },
 }
 
 #[inline(always)]
@@ -765,8 +771,8 @@ where
     Q: QueryConfig<Qcx>,
     Qcx: QueryContext,
 {
-    let dep_node = if let QueryMode::Ensure = mode {
-        let (must_run, dep_node) = ensure_must_run(query, qcx, &key);
+    let dep_node = if let QueryMode::Ensure { check_cache } = mode {
+        let (must_run, dep_node) = ensure_must_run(query, qcx, &key, check_cache);
         if !must_run {
             return None;
         }