Skip to content

Commit f52773b

Browse files
committed
Remove trivial QueryVTable methods.
These are now just trivial wrappers around the fn ptrs. Might as well just call the fn ptrs directly.
1 parent c3a27dd commit f52773b

5 files changed

Lines changed: 13 additions & 49 deletions

File tree

compiler/rustc_macros/src/query.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ pub(super) fn rustc_queries(input: TokenStream) -> TokenStream {
406406
// `(cache_on_disk { <closure > }`.
407407
if let Some(CacheOnDiskIf { block, .. }) = &modifiers.cache_on_disk_if {
408408
modifiers_out.push(quote! {
409-
(cache_on_disk_if {
409+
(cache_on_disk_if {
410410
// `pass_by_value`: some keys are marked with `rustc_pass_by_value`, but we
411411
// take keys by reference here.
412412
// FIXME: `pass_by_value` is badly named; `allow(rustc::pass_by_value)`

compiler/rustc_middle/src/query/plumbing.rs

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,6 @@ impl<'tcx, C: QueryCache> fmt::Debug for QueryVTable<'tcx, C> {
172172
}
173173

174174
impl<'tcx, C: QueryCache> QueryVTable<'tcx, C> {
175-
#[inline(always)]
176-
pub fn will_cache_on_disk_for_key(&self, tcx: TyCtxt<'tcx>, key: &C::Key) -> bool {
177-
(self.will_cache_on_disk_for_key_fn)(tcx, key)
178-
}
179-
180175
// Don't use this method to access query results, instead use the methods on TyCtxt.
181176
#[inline(always)]
182177
pub fn query_state(&self, tcx: TyCtxt<'tcx>) -> &'tcx QueryState<'tcx, C::Key> {
@@ -201,37 +196,6 @@ impl<'tcx, C: QueryCache> QueryVTable<'tcx, C> {
201196
}
202197
}
203198

204-
#[inline(always)]
205-
pub fn try_load_from_disk(
206-
&self,
207-
tcx: TyCtxt<'tcx>,
208-
key: &C::Key,
209-
prev_index: SerializedDepNodeIndex,
210-
index: DepNodeIndex,
211-
) -> Option<C::Value> {
212-
(self.try_load_from_disk_fn)(tcx, key, prev_index, index)
213-
}
214-
215-
#[inline]
216-
pub fn is_loadable_from_disk(
217-
&self,
218-
tcx: TyCtxt<'tcx>,
219-
key: &C::Key,
220-
index: SerializedDepNodeIndex,
221-
) -> bool {
222-
(self.is_loadable_from_disk_fn)(tcx, key, index)
223-
}
224-
225-
/// Synthesize an error value to let compilation continue after a cycle.
226-
pub fn value_from_cycle_error(
227-
&self,
228-
tcx: TyCtxt<'tcx>,
229-
cycle_error: &CycleError,
230-
guar: ErrorGuaranteed,
231-
) -> C::Value {
232-
(self.value_from_cycle_error)(tcx, cycle_error, guar)
233-
}
234-
235199
pub fn construct_dep_node(&self, tcx: TyCtxt<'tcx>, key: &C::Key) -> DepNode {
236200
DepNode::construct(tcx, self.dep_kind, key)
237201
}

compiler/rustc_query_impl/src/execution.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ fn handle_cycle_error<'tcx, C: QueryCache>(
120120
match query.cycle_error_handling {
121121
CycleErrorHandling::Error => {
122122
let guar = error.emit();
123-
query.value_from_cycle_error(tcx, cycle_error, guar)
123+
(query.value_from_cycle_error)(tcx, cycle_error, guar)
124124
}
125125
CycleErrorHandling::Fatal => {
126126
error.emit();
@@ -129,7 +129,7 @@ fn handle_cycle_error<'tcx, C: QueryCache>(
129129
}
130130
CycleErrorHandling::DelayBug => {
131131
let guar = error.delay_as_bug();
132-
query.value_from_cycle_error(tcx, cycle_error, guar)
132+
(query.value_from_cycle_error)(tcx, cycle_error, guar)
133133
}
134134
CycleErrorHandling::Stash => {
135135
let guar = if let Some(root) = cycle_error.cycle.first()
@@ -139,7 +139,7 @@ fn handle_cycle_error<'tcx, C: QueryCache>(
139139
} else {
140140
error.emit()
141141
};
142-
query.value_from_cycle_error(tcx, cycle_error, guar)
142+
(query.value_from_cycle_error)(tcx, cycle_error, guar)
143143
}
144144
}
145145
}
@@ -508,7 +508,9 @@ fn try_load_from_disk_and_cache_in_memory<'tcx, C: QueryCache>(
508508

509509
// First we try to load the result from the on-disk cache.
510510
// Some things are never cached on disk.
511-
if let Some(result) = query.try_load_from_disk(tcx, key, prev_dep_node_index, dep_node_index) {
511+
if let Some(result) =
512+
(query.try_load_from_disk_fn)(tcx, key, prev_dep_node_index, dep_node_index)
513+
{
512514
if std::intrinsics::unlikely(tcx.sess.opts.unstable_opts.query_dep_graph) {
513515
dep_graph_data.mark_debug_loaded_from_disk(*dep_node)
514516
}
@@ -541,15 +543,15 @@ fn try_load_from_disk_and_cache_in_memory<'tcx, C: QueryCache>(
541543
// We always expect to find a cached result for things that
542544
// can be forced from `DepNode`.
543545
debug_assert!(
544-
!query.will_cache_on_disk_for_key(tcx, key)
546+
!(query.will_cache_on_disk_for_key_fn)(tcx, key)
545547
|| !tcx.key_fingerprint_style(dep_node.kind).reconstructible(),
546548
"missing on-disk cache entry for {dep_node:?}"
547549
);
548550

549551
// Sanity check for the logic in `ensure`: if the node is green and the result loadable,
550552
// we should actually be able to load it.
551553
debug_assert!(
552-
!query.is_loadable_from_disk(tcx, key, prev_dep_node_index),
554+
!(query.is_loadable_from_disk_fn)(tcx, key, prev_dep_node_index),
553555
"missing on-disk cache entry for loadable {dep_node:?}"
554556
);
555557

@@ -646,7 +648,7 @@ fn check_if_ensure_can_skip_execution<'tcx, C: QueryCache>(
646648
// In ensure-done mode, we can only skip execution for this key if
647649
// there's a disk-cached value available to load later if needed,
648650
// which guarantees the query provider will never run for this key.
649-
let is_loadable = query.is_loadable_from_disk(tcx, key, serialized_dep_node_index);
651+
let is_loadable = (query.is_loadable_from_disk_fn)(tcx, key, serialized_dep_node_index);
650652
EnsureCanSkip { skip_execution: is_loadable, dep_node: Some(dep_node) }
651653
}
652654
}

compiler/rustc_query_impl/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ use rustc_middle::queries::{
2121
};
2222
use rustc_middle::query::on_disk_cache::{CacheEncoder, EncodedDepNodeIndex, OnDiskCache};
2323
use rustc_middle::query::plumbing::{QuerySystem, QuerySystemFns, QueryVTable};
24-
use rustc_middle::query::{
25-
AsLocalKey, QueryCache, QueryMode, describe_as_module,
26-
};
24+
use rustc_middle::query::{AsLocalKey, QueryCache, QueryMode, describe_as_module};
2725
use rustc_middle::ty::print::PrintTraitRefExt;
2826
use rustc_middle::ty::{self, PseudoCanonicalInput, TyCtxt};
2927
use rustc_span::def_id::{CrateNum, DefId, LocalDefId, LocalModDefId};

compiler/rustc_query_impl/src/plumbing.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ pub(crate) fn encode_query_results_inner<'a, 'tcx, C, V>(
358358
assert!(all_inactive(query.query_state(tcx)));
359359
let cache = query.query_cache(tcx);
360360
cache.iter(&mut |key, value, dep_node| {
361-
if query.will_cache_on_disk_for_key(tcx, key) {
361+
if (query.will_cache_on_disk_for_key_fn)(tcx, key) {
362362
let dep_node = SerializedDepNodeIndex::new(dep_node.index());
363363

364364
// Record position of the cache entry.
@@ -411,7 +411,7 @@ pub(crate) fn try_load_from_on_disk_cache_inner<'tcx, C: QueryCache>(
411411
dep_node.key_fingerprint
412412
)
413413
});
414-
if query.will_cache_on_disk_for_key(tcx, &key) {
414+
if (query.will_cache_on_disk_for_key_fn)(tcx, &key) {
415415
// Call `tcx.$query(key)` for its side-effect of loading the disk-cached
416416
// value into memory.
417417
(query.call_query_method_fn)(tcx, key);

0 commit comments

Comments
 (0)