From 7208bdee33460b9915e6b389b236d231d2ca3ffc Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Thu, 1 Sep 2022 22:26:03 -0500 Subject: Remove `cache_on_disk` from `QueryVTable` This is not only simpler, but removes a generic function and unwrap. I have hope it will see compile time and bootstrap time improvements. --- compiler/rustc_query_system/src/query/config.rs | 10 ++-------- compiler/rustc_query_system/src/query/plumbing.rs | 6 +++--- 2 files changed, 5 insertions(+), 11 deletions(-) (limited to 'compiler/rustc_query_system/src') 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 { 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, &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 Option>, } @@ -44,13 +45,6 @@ impl QueryVTable { 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 { - self.try_load_from_disk - .expect("QueryDescription::load_from_disk() called for an unsupported query.")( - tcx, index, - ) - } } pub trait QueryDescription: 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()); -- cgit 1.4.1-3-g733a5