diff options
| -rw-r--r-- | compiler/rustc_query_impl/src/plumbing.rs | 3 | ||||
| -rw-r--r-- | compiler/rustc_query_system/src/query/config.rs | 10 | ||||
| -rw-r--r-- | compiler/rustc_query_system/src/query/plumbing.rs | 6 |
3 files changed, 6 insertions, 13 deletions
diff --git a/compiler/rustc_query_impl/src/plumbing.rs b/compiler/rustc_query_impl/src/plumbing.rs index 48539d580c7..4ff3917e113 100644 --- a/compiler/rustc_query_impl/src/plumbing.rs +++ b/compiler/rustc_query_impl/src/plumbing.rs @@ -442,8 +442,7 @@ macro_rules! define_queries { hash_result: hash_result!([$($modifiers)*]), handle_cycle_error: handle_cycle_error!([$($modifiers)*]), compute, - cache_on_disk, - try_load_from_disk: Self::TRY_LOAD_FROM_DISK, + try_load_from_disk: if cache_on_disk { Self::TRY_LOAD_FROM_DISK } else { None }, } } diff --git a/compiler/rustc_query_system/src/query/config.rs b/compiler/rustc_query_system/src/query/config.rs index c63e110a62e..340deb88915 100644 --- a/compiler/rustc_query_system/src/query/config.rs +++ b/compiler/rustc_query_system/src/query/config.rs @@ -25,11 +25,12 @@ pub struct QueryVTable<CTX: QueryContext, K, V> { pub dep_kind: CTX::DepKind, pub eval_always: bool, pub depth_limit: bool, - pub cache_on_disk: bool, pub compute: fn(CTX::DepContext, K) -> V, pub hash_result: Option<fn(&mut StableHashingContext<'_>, &V) -> Fingerprint>, pub handle_cycle_error: HandleCycleError, + // NOTE: this is not quite the same as `Q::TRY_LOAD_FROM_DISK`; it can also be `None` if + // `cache_on_disk` returned false for this key. pub try_load_from_disk: Option<fn(CTX, SerializedDepNodeIndex) -> Option<V>>, } @@ -44,13 +45,6 @@ impl<CTX: QueryContext, K, V> QueryVTable<CTX, K, V> { pub(crate) fn compute(&self, tcx: CTX::DepContext, key: K) -> V { (self.compute)(tcx, key) } - - pub(crate) fn try_load_from_disk(&self, tcx: CTX, index: SerializedDepNodeIndex) -> Option<V> { - self.try_load_from_disk - .expect("QueryDescription::load_from_disk() called for an unsupported query.")( - tcx, index, - ) - } } pub trait QueryDescription<CTX: QueryContext>: QueryConfig { diff --git a/compiler/rustc_query_system/src/query/plumbing.rs b/compiler/rustc_query_system/src/query/plumbing.rs index e39e39860cb..8179a674afa 100644 --- a/compiler/rustc_query_system/src/query/plumbing.rs +++ b/compiler/rustc_query_system/src/query/plumbing.rs @@ -488,14 +488,14 @@ where // First we try to load the result from the on-disk cache. // Some things are never cached on disk. - if query.cache_on_disk { + if let Some(try_load_from_disk) = query.try_load_from_disk { let prof_timer = tcx.dep_context().profiler().incr_cache_loading(); // The call to `with_query_deserialization` enforces that no new `DepNodes` // are created during deserialization. See the docs of that method for more // details. - let result = dep_graph - .with_query_deserialization(|| query.try_load_from_disk(tcx, prev_dep_node_index)); + let result = + dep_graph.with_query_deserialization(|| try_load_from_disk(tcx, prev_dep_node_index)); prof_timer.finish_with_query_invocation_id(dep_node_index.into()); |
