summaryrefslogtreecommitdiff
path: root/compiler/rustc_query_impl
diff options
context:
space:
mode:
authorNilstrieb <48135649+Nilstrieb@users.noreply.github.com>2022-12-30 23:25:19 +0100
committerNilstrieb <48135649+Nilstrieb@users.noreply.github.com>2023-01-02 20:22:19 +0100
commit9fe4efe115171dca0dd24b3f1dc3d60e87e0792d (patch)
treeb32f3a322631da2288857a3056af6c634e30a6f3 /compiler/rustc_query_impl
parente5e5fcb0b758fcf7f149cc9206155dcfa18ec909 (diff)
downloadrust-9fe4efe115171dca0dd24b3f1dc3d60e87e0792d.tar.gz
Abolish `QueryVTable` in favour of more assoc items on `QueryConfig`
This may introduce additional mono _but_ may help const fold things better and especially may help not constructing a `QueryVTable` anymore which is cheap but not free.
Diffstat (limited to 'compiler/rustc_query_impl')
-rw-r--r--compiler/rustc_query_impl/src/lib.rs1
-rw-r--r--compiler/rustc_query_impl/src/plumbing.rs40
2 files changed, 22 insertions, 19 deletions
diff --git a/compiler/rustc_query_impl/src/lib.rs b/compiler/rustc_query_impl/src/lib.rs
index d426a2b6b78..2d243e13cc2 100644
--- a/compiler/rustc_query_impl/src/lib.rs
+++ b/compiler/rustc_query_impl/src/lib.rs
@@ -34,7 +34,6 @@ use rustc_query_system::query::*;
pub use rustc_query_system::query::{deadlock, QueryContext};
pub use rustc_query_system::query::QueryConfig;
-pub(crate) use rustc_query_system::query::QueryVTable;
mod on_disk_cache;
pub use on_disk_cache::OnDiskCache;
diff --git a/compiler/rustc_query_impl/src/plumbing.rs b/compiler/rustc_query_impl/src/plumbing.rs
index 9ffcc5672cc..535445e70bc 100644
--- a/compiler/rustc_query_impl/src/plumbing.rs
+++ b/compiler/rustc_query_impl/src/plumbing.rs
@@ -493,28 +493,32 @@ macro_rules! define_queries {
&tcx.query_caches.$name
}
+ fn execute_query(tcx: TyCtxt<'tcx>, key: Self::Key) -> Self::Stored {
+ tcx.$name(key)
+ }
+
#[inline]
- fn make_vtable(tcx: QueryCtxt<'tcx>, key: &Self::Key) ->
- QueryVTable<QueryCtxt<'tcx>, Self::Key, Self::Value>
- {
- let compute = get_provider!([$($modifiers)*][tcx, $name, key]);
- let cache_on_disk = Self::cache_on_disk(tcx.tcx, key);
- QueryVTable {
- anon: is_anon!([$($modifiers)*]),
- eval_always: is_eval_always!([$($modifiers)*]),
- depth_limit: depth_limit!([$($modifiers)*]),
- feedable: feedable!([$($modifiers)*]),
- dep_kind: dep_graph::DepKind::$name,
- hash_result: hash_result!([$($modifiers)*]),
- handle_cycle_error: handle_cycle_error!([$($modifiers)*]),
- compute,
- try_load_from_disk: if cache_on_disk { should_ever_cache_on_disk!([$($modifiers)*]) } else { None },
- }
+ // key is only sometimes used
+ #[allow(unused_variables)]
+ fn compute(qcx: QueryCtxt<'tcx>, key: &Self::Key) -> fn(TyCtxt<'tcx>, Self::Key) -> Self::Value {
+ get_provider!([$($modifiers)*][qcx, $name, key])
}
- fn execute_query(tcx: TyCtxt<'tcx>, k: Self::Key) -> Self::Stored {
- tcx.$name(k)
+ #[inline]
+ fn try_load_from_disk(qcx: QueryCtxt<'tcx>, key: &Self::Key) -> rustc_query_system::query::TryLoadFromDisk<QueryCtxt<'tcx>, Self> {
+ let cache_on_disk = Self::cache_on_disk(qcx.tcx, key);
+ if cache_on_disk { should_ever_cache_on_disk!([$($modifiers)*]) } else { None }
}
+
+ const ANON: bool = is_anon!([$($modifiers)*]);
+ const EVAL_ALWAYS: bool = is_eval_always!([$($modifiers)*]);
+ const DEPTH_LIMIT: bool = depth_limit!([$($modifiers)*]);
+ const FEEDABLE: bool = feedable!([$($modifiers)*]);
+
+ const DEP_KIND: rustc_middle::dep_graph::DepKind = dep_graph::DepKind::$name;
+ const HANDLE_CYCLE_ERROR: rustc_query_system::HandleCycleError = handle_cycle_error!([$($modifiers)*]);
+
+ const HASH_RESULT: rustc_query_system::query::HashResult<QueryCtxt<'tcx>, Self> = hash_result!([$($modifiers)*]);
})*
#[allow(nonstandard_style)]