Skip to content

Commit 9cc3fcd

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 462ae37 commit 9cc3fcd

File tree

5 files changed

+13
-49
lines changed

5 files changed

+13
-49
lines changed

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
@@ -170,42 +170,6 @@ impl<'tcx, C: QueryCache> fmt::Debug for QueryVTable<'tcx, C> {
170170
}
171171

172172
impl<'tcx, C: QueryCache> QueryVTable<'tcx, C> {
173-
#[inline(always)]
174-
pub fn will_cache_on_disk_for_key(&self, tcx: TyCtxt<'tcx>, key: &C::Key) -> bool {
175-
(self.will_cache_on_disk_for_key_fn)(tcx, key)
176-
}
177-
178-
#[inline(always)]
179-
pub fn try_load_from_disk(
180-
&self,
181-
tcx: TyCtxt<'tcx>,
182-
key: &C::Key,
183-
prev_index: SerializedDepNodeIndex,
184-
index: DepNodeIndex,
185-
) -> Option<C::Value> {
186-
(self.try_load_from_disk_fn)(tcx, key, prev_index, index)
187-
}
188-
189-
#[inline]
190-
pub fn is_loadable_from_disk(
191-
&self,
192-
tcx: TyCtxt<'tcx>,
193-
key: &C::Key,
194-
index: SerializedDepNodeIndex,
195-
) -> bool {
196-
(self.is_loadable_from_disk_fn)(tcx, key, index)
197-
}
198-
199-
/// Synthesize an error value to let compilation continue after a cycle.
200-
pub fn value_from_cycle_error(
201-
&self,
202-
tcx: TyCtxt<'tcx>,
203-
cycle_error: &CycleError,
204-
guar: ErrorGuaranteed,
205-
) -> C::Value {
206-
(self.value_from_cycle_error)(tcx, cycle_error, guar)
207-
}
208-
209173
pub fn construct_dep_node(&self, tcx: TyCtxt<'tcx>, key: &C::Key) -> DepNode {
210174
DepNode::construct(tcx, self.dep_kind, key)
211175
}

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
}
@@ -506,7 +506,9 @@ fn try_load_from_disk_and_cache_in_memory<'tcx, C: QueryCache>(
506506

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

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

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

compiler/rustc_query_impl/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ use rustc_middle::mir::mono::CollectionMode;
1919
use rustc_middle::queries::{self, ExternProviders, Providers};
2020
use rustc_middle::query::on_disk_cache::{CacheEncoder, EncodedDepNodeIndex, OnDiskCache};
2121
use rustc_middle::query::plumbing::{QuerySystem, QuerySystemFns, QueryVTable};
22-
use rustc_middle::query::{
23-
AsLocalKey, QueryCache, QueryMode, describe_as_module,
24-
};
22+
use rustc_middle::query::{AsLocalKey, QueryCache, QueryMode, describe_as_module};
2523
use rustc_middle::ty::print::PrintTraitRefExt;
2624
use rustc_middle::ty::{self, PseudoCanonicalInput, TyCtxt};
2725
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

359359
assert!(all_inactive(&query.state));
360360
query.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)