Inline and remove QueryVTable::is_loadable_from_disk_fn.

It's very small and only has two call sites. The tiny loss of DRY is
worth it to shrink `QueryVTable`.
This commit is contained in:
Nicholas Nethercote
2026-03-22 14:32:43 +11:00
parent 562dee4820
commit 5841fa8650
3 changed files with 4 additions and 14 deletions
@@ -104,9 +104,6 @@ pub struct QueryVTable<'tcx, C: QueryCache> {
index: DepNodeIndex,
) -> Option<C::Value>,
pub is_loadable_from_disk_fn:
fn(tcx: TyCtxt<'tcx>, key: C::Key, index: SerializedDepNodeIndex) -> bool,
/// Function pointer that hashes this query's result values.
///
/// For `no_hash` queries, this function pointer is None.
+4 -3
View File
@@ -18,7 +18,7 @@
use crate::dep_graph::{DepNode, DepNodeIndex};
use crate::job::{QueryJobInfo, QueryJobMap, find_cycle_in_stack, report_cycle};
use crate::plumbing::{current_query_job, next_job_id, start_query};
use crate::plumbing::{current_query_job, loadable_from_disk, next_job_id, start_query};
use crate::query_impl::for_each_query_vtable;
#[inline]
@@ -531,7 +531,7 @@ fn load_from_disk_or_invoke_provider_green<'tcx, C: QueryCache>(
// Sanity check for the logic in `ensure`: if the node is green and the result loadable,
// we should actually be able to load it.
debug_assert!(
!(query.is_loadable_from_disk_fn)(tcx, key, prev_index),
!((query.will_cache_on_disk_for_key_fn)(tcx, key) && loadable_from_disk(tcx, prev_index)),
"missing on-disk cache entry for loadable {dep_node:?}"
);
@@ -624,7 +624,8 @@ fn check_if_ensure_can_skip_execution<'tcx, C: QueryCache>(
// In ensure-done mode, we can only skip execution for this key if
// there's a disk-cached value available to load later if needed,
// which guarantees the query provider will never run for this key.
let is_loadable = (query.is_loadable_from_disk_fn)(tcx, key, serialized_dep_node_index);
let is_loadable = (query.will_cache_on_disk_for_key_fn)(tcx, key)
&& loadable_from_disk(tcx, serialized_dep_node_index);
EnsureCanSkip { skip_execution: is_loadable, dep_node: Some(dep_node) }
}
}
@@ -165,14 +165,6 @@ pub(crate) fn make_query_vtable<'tcx>(incremental: bool)
#[cfg(not($cache_on_disk))]
try_load_from_disk_fn: |_tcx, _key, _prev_index, _index| None,
#[cfg($cache_on_disk)]
is_loadable_from_disk_fn: |tcx, key, index| -> bool {
rustc_middle::queries::_cache_on_disk_if_fns::$name(tcx, key) &&
$crate::plumbing::loadable_from_disk(tcx, index)
},
#[cfg(not($cache_on_disk))]
is_loadable_from_disk_fn: |_tcx, _key, _index| false,
// The default just emits `err` and then aborts.
// `from_cycle_error::specialize_query_vtables` overwrites this default for
// certain queries.