diff options
Diffstat (limited to 'compiler/rustc_query_system/src/query')
| -rw-r--r-- | compiler/rustc_query_system/src/query/config.rs | 32 | ||||
| -rw-r--r-- | compiler/rustc_query_system/src/query/job.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_query_system/src/query/plumbing.rs | 112 |
3 files changed, 74 insertions, 74 deletions
diff --git a/compiler/rustc_query_system/src/query/config.rs b/compiler/rustc_query_system/src/query/config.rs index db3ae559ad1..f40e174b7e7 100644 --- a/compiler/rustc_query_system/src/query/config.rs +++ b/compiler/rustc_query_system/src/query/config.rs @@ -11,7 +11,7 @@ use rustc_data_structures::fingerprint::Fingerprint; use std::fmt::Debug; use std::hash::Hash; -pub trait QueryConfig<CTX: QueryContext> { +pub trait QueryConfig<Qcx: QueryContext> { const NAME: &'static str; type Key: Eq + Hash + Clone + Debug; @@ -21,47 +21,47 @@ pub trait QueryConfig<CTX: QueryContext> { type Cache: QueryCache<Key = Self::Key, Stored = Self::Stored, Value = Self::Value>; // Don't use this method to access query results, instead use the methods on TyCtxt - fn query_state<'a>(tcx: CTX) -> &'a QueryState<Self::Key> + fn query_state<'a>(tcx: Qcx) -> &'a QueryState<Self::Key> where - CTX: 'a; + Qcx: 'a; // Don't use this method to access query results, instead use the methods on TyCtxt - fn query_cache<'a>(tcx: CTX) -> &'a Self::Cache + fn query_cache<'a>(tcx: Qcx) -> &'a Self::Cache where - CTX: 'a; + Qcx: 'a; // Don't use this method to compute query results, instead use the methods on TyCtxt - fn make_vtable(tcx: CTX, key: &Self::Key) -> QueryVTable<CTX, Self::Key, Self::Value>; + fn make_vtable(tcx: Qcx, key: &Self::Key) -> QueryVTable<Qcx, Self::Key, Self::Value>; - fn cache_on_disk(tcx: CTX::DepContext, key: &Self::Key) -> bool; + fn cache_on_disk(tcx: Qcx::DepContext, key: &Self::Key) -> bool; // Don't use this method to compute query results, instead use the methods on TyCtxt - fn execute_query(tcx: CTX::DepContext, k: Self::Key) -> Self::Stored; + fn execute_query(tcx: Qcx::DepContext, k: Self::Key) -> Self::Stored; } #[derive(Copy, Clone)] -pub struct QueryVTable<CTX: QueryContext, K, V> { +pub struct QueryVTable<Qcx: QueryContext, K, V> { pub anon: bool, - pub dep_kind: CTX::DepKind, + pub dep_kind: Qcx::DepKind, pub eval_always: bool, pub depth_limit: bool, - pub compute: fn(CTX::DepContext, K) -> V, + pub compute: fn(Qcx::DepContext, K) -> V, pub hash_result: Option<fn(&mut StableHashingContext<'_>, &V) -> Fingerprint>, pub handle_cycle_error: HandleCycleError, // NOTE: this is also `None` if `cache_on_disk()` returns false, not just if it's unsupported by the query - pub try_load_from_disk: Option<fn(CTX, SerializedDepNodeIndex) -> Option<V>>, + pub try_load_from_disk: Option<fn(Qcx, SerializedDepNodeIndex) -> Option<V>>, } -impl<CTX: QueryContext, K, V> QueryVTable<CTX, K, V> { - pub(crate) fn to_dep_node(&self, tcx: CTX::DepContext, key: &K) -> DepNode<CTX::DepKind> +impl<Qcx: QueryContext, K, V> QueryVTable<Qcx, K, V> { + pub(crate) fn to_dep_node(&self, tcx: Qcx::DepContext, key: &K) -> DepNode<Qcx::DepKind> where - K: crate::dep_graph::DepNodeParams<CTX::DepContext>, + K: crate::dep_graph::DepNodeParams<Qcx::DepContext>, { DepNode::construct(tcx, self.dep_kind, key) } - pub(crate) fn compute(&self, tcx: CTX::DepContext, key: K) -> V { + pub(crate) fn compute(&self, tcx: Qcx::DepContext, key: K) -> V { (self.compute)(tcx, key) } } diff --git a/compiler/rustc_query_system/src/query/job.rs b/compiler/rustc_query_system/src/query/job.rs index bd21b5465e2..49bbcf57804 100644 --- a/compiler/rustc_query_system/src/query/job.rs +++ b/compiler/rustc_query_system/src/query/job.rs @@ -596,8 +596,8 @@ pub(crate) fn report_cycle<'a>( cycle_diag.into_diagnostic(&sess.parse_sess.span_diagnostic) } -pub fn print_query_stack<CTX: QueryContext>( - qcx: CTX, +pub fn print_query_stack<Qcx: QueryContext>( + qcx: Qcx, mut current_query: Option<QueryJobId>, handler: &Handler, num_frames: Option<usize>, diff --git a/compiler/rustc_query_system/src/query/plumbing.rs b/compiler/rustc_query_system/src/query/plumbing.rs index 6348bc6b3af..f8d93a27d1c 100644 --- a/compiler/rustc_query_system/src/query/plumbing.rs +++ b/compiler/rustc_query_system/src/query/plumbing.rs @@ -62,10 +62,10 @@ where } } - pub fn try_collect_active_jobs<CTX: Copy>( + pub fn try_collect_active_jobs<Qcx: Copy>( &self, - qcx: CTX, - make_query: fn(CTX, K) -> QueryStackFrame, + qcx: Qcx, + make_query: fn(Qcx, K) -> QueryStackFrame, jobs: &mut QueryMap, ) -> Option<()> { #[cfg(parallel_compiler)] @@ -119,15 +119,15 @@ where #[cold] #[inline(never)] -fn mk_cycle<CTX, V, R>( - qcx: CTX, +fn mk_cycle<Qcx, V, R>( + qcx: Qcx, cycle_error: CycleError, handler: HandleCycleError, cache: &dyn crate::query::QueryStorage<Value = V, Stored = R>, ) -> R where - CTX: QueryContext, - V: std::fmt::Debug + Value<CTX::DepContext>, + Qcx: QueryContext, + V: std::fmt::Debug + Value<Qcx::DepContext>, R: Clone, { let error = report_cycle(qcx.dep_context().sess(), &cycle_error); @@ -135,15 +135,15 @@ where cache.store_nocache(value) } -fn handle_cycle_error<CTX, V>( - tcx: CTX, +fn handle_cycle_error<Tcx, V>( + tcx: Tcx, cycle_error: &CycleError, mut error: DiagnosticBuilder<'_, ErrorGuaranteed>, handler: HandleCycleError, ) -> V where - CTX: DepContext, - V: Value<CTX>, + Tcx: DepContext, + V: Value<Tcx>, { use HandleCycleError::*; match handler { @@ -176,14 +176,14 @@ where /// This function is inlined because that results in a noticeable speed-up /// for some compile-time benchmarks. #[inline(always)] - fn try_start<'b, CTX>( - qcx: &'b CTX, + fn try_start<'b, Qcx>( + qcx: &'b Qcx, state: &'b QueryState<K>, span: Span, key: K, ) -> TryGetJob<'b, K> where - CTX: QueryContext, + Qcx: QueryContext, { #[cfg(parallel_compiler)] let mut state_lock = state.active.get_shard_by_value(&key).lock(); @@ -335,8 +335,8 @@ where /// which will be used if the query is not in the cache and we need /// to compute it. #[inline] -pub fn try_get_cached<'a, CTX, C, R, OnHit>( - tcx: CTX, +pub fn try_get_cached<'a, Tcx, C, R, OnHit>( + tcx: Tcx, cache: &'a C, key: &C::Key, // `on_hit` can be called while holding a lock to the query cache @@ -344,7 +344,7 @@ pub fn try_get_cached<'a, CTX, C, R, OnHit>( ) -> Result<R, ()> where C: QueryCache, - CTX: DepContext, + Tcx: DepContext, OnHit: FnOnce(&C::Stored) -> R, { cache.lookup(&key, |value, index| { @@ -356,20 +356,20 @@ where }) } -fn try_execute_query<CTX, C>( - qcx: CTX, +fn try_execute_query<Qcx, C>( + qcx: Qcx, state: &QueryState<C::Key>, cache: &C, span: Span, key: C::Key, - dep_node: Option<DepNode<CTX::DepKind>>, - query: &QueryVTable<CTX, C::Key, C::Value>, + dep_node: Option<DepNode<Qcx::DepKind>>, + query: &QueryVTable<Qcx, C::Key, C::Value>, ) -> (C::Stored, Option<DepNodeIndex>) where C: QueryCache, - C::Key: Clone + DepNodeParams<CTX::DepContext>, - C::Value: Value<CTX::DepContext>, - CTX: QueryContext, + C::Key: Clone + DepNodeParams<Qcx::DepContext>, + C::Value: Value<Qcx::DepContext>, + Qcx: QueryContext, { match JobOwner::<'_, C::Key>::try_start(&qcx, state, span, key.clone()) { TryGetJob::NotYetStarted(job) => { @@ -397,17 +397,17 @@ where } } -fn execute_job<CTX, K, V>( - qcx: CTX, +fn execute_job<Qcx, K, V>( + qcx: Qcx, key: K, - mut dep_node_opt: Option<DepNode<CTX::DepKind>>, - query: &QueryVTable<CTX, K, V>, + mut dep_node_opt: Option<DepNode<Qcx::DepKind>>, + query: &QueryVTable<Qcx, K, V>, job_id: QueryJobId, ) -> (V, DepNodeIndex) where - K: Clone + DepNodeParams<CTX::DepContext>, + K: Clone + DepNodeParams<Qcx::DepContext>, V: Debug, - CTX: QueryContext, + Qcx: QueryContext, { let dep_graph = qcx.dep_context().dep_graph(); @@ -470,15 +470,15 @@ where (result, dep_node_index) } -fn try_load_from_disk_and_cache_in_memory<CTX, K, V>( - qcx: CTX, +fn try_load_from_disk_and_cache_in_memory<Qcx, K, V>( + qcx: Qcx, key: &K, - dep_node: &DepNode<CTX::DepKind>, - query: &QueryVTable<CTX, K, V>, + dep_node: &DepNode<Qcx::DepKind>, + query: &QueryVTable<Qcx, K, V>, ) -> Option<(V, DepNodeIndex)> where K: Clone, - CTX: QueryContext, + Qcx: QueryContext, V: Debug, { // Note this function can be called concurrently from the same query @@ -564,13 +564,13 @@ where } #[instrument(skip(qcx, result, query), level = "debug")] -fn incremental_verify_ich<CTX, K, V: Debug>( - qcx: CTX::DepContext, +fn incremental_verify_ich<Qcx, K, V: Debug>( + qcx: Qcx::DepContext, result: &V, - dep_node: &DepNode<CTX::DepKind>, - query: &QueryVTable<CTX, K, V>, + dep_node: &DepNode<Qcx::DepKind>, + query: &QueryVTable<Qcx, K, V>, ) where - CTX: QueryContext, + Qcx: QueryContext, { assert!( qcx.dep_graph().is_green(dep_node), @@ -676,14 +676,14 @@ fn incremental_verify_ich_failed(sess: &Session, dep_node: DebugArg<'_>, result: /// /// Note: The optimization is only available during incr. comp. #[inline(never)] -fn ensure_must_run<CTX, K, V>( - qcx: CTX, +fn ensure_must_run<Qcx, K, V>( + qcx: Qcx, key: &K, - query: &QueryVTable<CTX, K, V>, -) -> (bool, Option<DepNode<CTX::DepKind>>) + query: &QueryVTable<Qcx, K, V>, +) -> (bool, Option<DepNode<Qcx::DepKind>>) where - K: crate::dep_graph::DepNodeParams<CTX::DepContext>, - CTX: QueryContext, + K: crate::dep_graph::DepNodeParams<Qcx::DepContext>, + Qcx: QueryContext, { if query.eval_always { return (true, None); @@ -719,12 +719,12 @@ pub enum QueryMode { Ensure, } -pub fn get_query<Q, CTX>(qcx: CTX, span: Span, key: Q::Key, mode: QueryMode) -> Option<Q::Stored> +pub fn get_query<Q, Qcx>(qcx: Qcx, span: Span, key: Q::Key, mode: QueryMode) -> Option<Q::Stored> where - Q: QueryConfig<CTX>, - Q::Key: DepNodeParams<CTX::DepContext>, - Q::Value: Value<CTX::DepContext>, - CTX: QueryContext, + Q: QueryConfig<Qcx>, + Q::Key: DepNodeParams<Qcx::DepContext>, + Q::Value: Value<Qcx::DepContext>, + Qcx: QueryContext, { let query = Q::make_vtable(qcx, &key); let dep_node = if let QueryMode::Ensure = mode { @@ -752,12 +752,12 @@ where Some(result) } -pub fn force_query<Q, CTX>(qcx: CTX, key: Q::Key, dep_node: DepNode<CTX::DepKind>) +pub fn force_query<Q, Qcx>(qcx: Qcx, key: Q::Key, dep_node: DepNode<Qcx::DepKind>) where - Q: QueryConfig<CTX>, - Q::Key: DepNodeParams<CTX::DepContext>, - Q::Value: Value<CTX::DepContext>, - CTX: QueryContext, + Q: QueryConfig<Qcx>, + Q::Key: DepNodeParams<Qcx::DepContext>, + Q::Value: Value<Qcx::DepContext>, + Qcx: QueryContext, { // We may be concurrently trying both execute and force a query. // Ensure that only one of them runs the query. |
