Skip to content

Commit 7208bde

Browse files
committed
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.
1 parent b164dbc commit 7208bde

File tree

3 files changed

+6
-13
lines changed

3 files changed

+6
-13
lines changed

compiler/rustc_query_impl/src/plumbing.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -442,8 +442,7 @@ macro_rules! define_queries {
442442
hash_result: hash_result!([$($modifiers)*]),
443443
handle_cycle_error: handle_cycle_error!([$($modifiers)*]),
444444
compute,
445-
cache_on_disk,
446-
try_load_from_disk: Self::TRY_LOAD_FROM_DISK,
445+
try_load_from_disk: if cache_on_disk { Self::TRY_LOAD_FROM_DISK } else { None },
447446
}
448447
}
449448

compiler/rustc_query_system/src/query/config.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@ pub struct QueryVTable<CTX: QueryContext, K, V> {
2525
pub dep_kind: CTX::DepKind,
2626
pub eval_always: bool,
2727
pub depth_limit: bool,
28-
pub cache_on_disk: bool,
2928

3029
pub compute: fn(CTX::DepContext, K) -> V,
3130
pub hash_result: Option<fn(&mut StableHashingContext<'_>, &V) -> Fingerprint>,
3231
pub handle_cycle_error: HandleCycleError,
32+
// NOTE: this is not quite the same as `Q::TRY_LOAD_FROM_DISK`; it can also be `None` if
33+
// `cache_on_disk` returned false for this key.
3334
pub try_load_from_disk: Option<fn(CTX, SerializedDepNodeIndex) -> Option<V>>,
3435
}
3536

@@ -44,13 +45,6 @@ impl<CTX: QueryContext, K, V> QueryVTable<CTX, K, V> {
4445
pub(crate) fn compute(&self, tcx: CTX::DepContext, key: K) -> V {
4546
(self.compute)(tcx, key)
4647
}
47-
48-
pub(crate) fn try_load_from_disk(&self, tcx: CTX, index: SerializedDepNodeIndex) -> Option<V> {
49-
self.try_load_from_disk
50-
.expect("QueryDescription::load_from_disk() called for an unsupported query.")(
51-
tcx, index,
52-
)
53-
}
5448
}
5549

5650
pub trait QueryDescription<CTX: QueryContext>: QueryConfig {

compiler/rustc_query_system/src/query/plumbing.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -488,14 +488,14 @@ where
488488

489489
// First we try to load the result from the on-disk cache.
490490
// Some things are never cached on disk.
491-
if query.cache_on_disk {
491+
if let Some(try_load_from_disk) = query.try_load_from_disk {
492492
let prof_timer = tcx.dep_context().profiler().incr_cache_loading();
493493

494494
// The call to `with_query_deserialization` enforces that no new `DepNodes`
495495
// are created during deserialization. See the docs of that method for more
496496
// details.
497-
let result = dep_graph
498-
.with_query_deserialization(|| query.try_load_from_disk(tcx, prev_dep_node_index));
497+
let result =
498+
dep_graph.with_query_deserialization(|| try_load_from_disk(tcx, prev_dep_node_index));
499499

500500
prof_timer.finish_with_query_invocation_id(dep_node_index.into());
501501

0 commit comments

Comments
 (0)