Skip to content

Commit e7fb201

Browse files
committed
Rename query_dispatcher and reduce its use.
It's now `query_vtable` because its return type changed. And thanks to the previous commit it can be manually inlined in several places. (The only remaining calls to it are in `make_dep_kind_vtable_for_query`, which are more challenging to remove.)
1 parent c556c19 commit e7fb201

3 files changed

Lines changed: 11 additions & 12 deletions

File tree

compiler/rustc_query_impl/src/dep_kind_vtables.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,10 @@ where
140140
is_eval_always,
141141
key_fingerprint_style,
142142
force_from_dep_node: Some(|tcx, dep_node, _| {
143-
force_from_dep_node_inner(Q::query_dispatcher(tcx), tcx, dep_node)
143+
force_from_dep_node_inner(Q::query_vtable(tcx), tcx, dep_node)
144144
}),
145145
try_load_from_on_disk_cache: Some(|tcx, dep_node| {
146-
try_load_from_on_disk_cache_inner(Q::query_dispatcher(tcx), tcx, dep_node)
146+
try_load_from_on_disk_cache_inner(Q::query_vtable(tcx), tcx, dep_node)
147147
}),
148148
name: Q::NAME,
149149
}

compiler/rustc_query_impl/src/lib.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,9 @@ mod job;
3737
mod profiling_support;
3838
mod values;
3939

40-
/// Provides access to vtable-like operations for a query
41-
/// (by creating a [`SemiDynamicQueryDispatcher`]),
42-
/// but also keeps track of the "unerased" value type of the query
43-
/// (i.e. the actual result type in the query declaration).
40+
/// Provides access to vtable-like operations for a query (by creating a
41+
/// `QueryVTable`), but also keeps track of the "unerased" value type of the
42+
/// query (i.e. the actual result type in the query declaration).
4443
///
4544
/// This trait allows some per-query code to be defined in generic functions
4645
/// with a trait bound, instead of having to be defined inline within a macro
@@ -53,7 +52,7 @@ trait QueryDispatcherUnerased<'tcx, C: QueryCache> {
5352

5453
const NAME: &'static &'static str;
5554

56-
fn query_dispatcher(tcx: TyCtxt<'tcx>) -> &'tcx QueryVTable<'tcx, C>;
55+
fn query_vtable(tcx: TyCtxt<'tcx>) -> &'tcx QueryVTable<'tcx, C>;
5756

5857
fn restore_val(value: C::Value) -> Self::UnerasedValue;
5958
}

compiler/rustc_query_impl/src/plumbing.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ macro_rules! define_queries {
503503
#[cfg(debug_assertions)]
504504
let _guard = tracing::span!(tracing::Level::TRACE, stringify!($name), ?key).entered();
505505
execution::get_query_incr(
506-
QueryType::query_dispatcher(tcx),
506+
&tcx.query_system.query_vtables.$name,
507507
tcx,
508508
span,
509509
key,
@@ -523,7 +523,7 @@ macro_rules! define_queries {
523523
__mode: QueryMode,
524524
) -> Option<Erased<queries::$name::Value<'tcx>>> {
525525
Some(execution::get_query_non_incr(
526-
QueryType::query_dispatcher(tcx),
526+
&tcx.query_system.query_vtables.$name,
527527
tcx,
528528
span,
529529
key,
@@ -632,7 +632,7 @@ macro_rules! define_queries {
632632
const NAME: &'static &'static str = &stringify!($name);
633633

634634
#[inline(always)]
635-
fn query_dispatcher(tcx: TyCtxt<'tcx>)
635+
fn query_vtable(tcx: TyCtxt<'tcx>)
636636
-> &'tcx QueryVTable<'tcx, queries::$name::Storage<'tcx>>
637637
{
638638
&tcx.query_system.query_vtables.$name
@@ -701,7 +701,7 @@ macro_rules! define_queries {
701701
query_impl::$name::QueryType<'tcx>,
702702
_
703703
> (
704-
query_impl::$name::QueryType::query_dispatcher(tcx),
704+
&tcx.query_system.query_vtables.$name,
705705
tcx,
706706
encoder,
707707
query_result_index,
@@ -711,7 +711,7 @@ macro_rules! define_queries {
711711

712712
pub(crate) fn query_key_hash_verify<'tcx>(tcx: TyCtxt<'tcx>) {
713713
$crate::plumbing::query_key_hash_verify(
714-
query_impl::$name::QueryType::query_dispatcher(tcx),
714+
&tcx.query_system.query_vtables.$name,
715715
tcx,
716716
)
717717
}

0 commit comments

Comments
 (0)