about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCamille GILLOT <gillot.camille@gmail.com>2020-03-07 18:45:44 +0100
committerCamille GILLOT <gillot.camille@gmail.com>2020-03-16 11:06:53 +0100
commit5557407fbb322dc1265ba3c05cd5474a20c2e1d3 (patch)
tree529b9e8deb392c9d49a0a7b689e4f6b2668f5c9f
parent3abd4753b7c9fa9a3855d4b41b557f81b3e06aab (diff)
downloadrust-5557407fbb322dc1265ba3c05cd5474a20c2e1d3.tar.gz
rust-5557407fbb322dc1265ba3c05cd5474a20c2e1d3.zip
Remove QueryState type alias.
-rw-r--r--src/librustc/ty/query/caches.rs6
-rw-r--r--src/librustc/ty/query/config.rs2
-rw-r--r--src/librustc/ty/query/plumbing.rs27
-rw-r--r--src/librustc/ty/query/profiling_support.rs4
-rw-r--r--src/librustc/ty/query/stats.rs4
5 files changed, 22 insertions, 21 deletions
diff --git a/src/librustc/ty/query/caches.rs b/src/librustc/ty/query/caches.rs
index 71523ea39ca..a11b3bcba3e 100644
--- a/src/librustc/ty/query/caches.rs
+++ b/src/librustc/ty/query/caches.rs
@@ -1,5 +1,5 @@
 use crate::dep_graph::DepNodeIndex;
-use crate::ty::query::plumbing::{QueryLookup, QueryStateImpl, QueryStateShard};
+use crate::ty::query::plumbing::{QueryLookup, QueryState, QueryStateShard};
 use crate::ty::TyCtxt;
 
 use rustc_data_structures::fx::FxHashMap;
@@ -23,7 +23,7 @@ pub(crate) trait QueryCache: Default {
     /// to compute it.
     fn lookup<'tcx, R, GetCache, OnHit, OnMiss>(
         &self,
-        state: &'tcx QueryStateImpl<'tcx, Self>,
+        state: &'tcx QueryState<'tcx, Self>,
         get_cache: GetCache,
         key: Self::Key,
         // `on_hit` can be called while holding a lock to the query state shard.
@@ -78,7 +78,7 @@ impl<K: Eq + Hash, V: Clone> QueryCache for DefaultCache<K, V> {
     #[inline(always)]
     fn lookup<'tcx, R, GetCache, OnHit, OnMiss>(
         &self,
-        state: &'tcx QueryStateImpl<'tcx, Self>,
+        state: &'tcx QueryState<'tcx, Self>,
         get_cache: GetCache,
         key: K,
         on_hit: OnHit,
diff --git a/src/librustc/ty/query/config.rs b/src/librustc/ty/query/config.rs
index 5b0653bd599..72a0fdf1567 100644
--- a/src/librustc/ty/query/config.rs
+++ b/src/librustc/ty/query/config.rs
@@ -33,7 +33,7 @@ pub(crate) trait QueryAccessors<'tcx>: QueryConfig<'tcx> {
     type Cache: QueryCache<Key = Self::Key, Value = Self::Value>;
 
     // Don't use this method to access query results, instead use the methods on TyCtxt
-    fn query_state<'a>(tcx: TyCtxt<'tcx>) -> &'a QueryState<'tcx, Self>;
+    fn query_state<'a>(tcx: TyCtxt<'tcx>) -> &'a QueryState<'tcx, Self::Cache>;
 
     fn to_dep_node(tcx: TyCtxt<'tcx>, key: &Self::Key) -> DepNode;
 
diff --git a/src/librustc/ty/query/plumbing.rs b/src/librustc/ty/query/plumbing.rs
index c2740733977..442b3edcafe 100644
--- a/src/librustc/ty/query/plumbing.rs
+++ b/src/librustc/ty/query/plumbing.rs
@@ -4,7 +4,7 @@
 
 use crate::dep_graph::{DepKind, DepNode, DepNodeIndex, SerializedDepNodeIndex};
 use crate::ty::query::caches::QueryCache;
-use crate::ty::query::config::{QueryAccessors, QueryDescription};
+use crate::ty::query::config::QueryDescription;
 use crate::ty::query::job::{QueryInfo, QueryJob, QueryJobId, QueryJobInfo, QueryShardJobId};
 use crate::ty::query::Query;
 use crate::ty::tls;
@@ -49,16 +49,14 @@ impl<'tcx, K, C: Default> Default for QueryStateShard<'tcx, K, C> {
     }
 }
 
-pub(crate) type QueryState<'tcx, Q> = QueryStateImpl<'tcx, <Q as QueryAccessors<'tcx>>::Cache>;
-
-pub(crate) struct QueryStateImpl<'tcx, C: QueryCache> {
+pub(crate) struct QueryState<'tcx, C: QueryCache> {
     pub(super) cache: C,
     pub(super) shards: Sharded<QueryStateShard<'tcx, C::Key, C::Sharded>>,
     #[cfg(debug_assertions)]
     pub(super) cache_hits: AtomicUsize,
 }
 
-impl<'tcx, C: QueryCache> QueryStateImpl<'tcx, C> {
+impl<'tcx, C: QueryCache> QueryState<'tcx, C> {
     pub(super) fn get_lookup<K2: Hash>(
         &'tcx self,
         key: &K2,
@@ -86,7 +84,7 @@ pub(super) enum QueryResult<'tcx> {
     Poisoned,
 }
 
-impl<'tcx, C: QueryCache> QueryStateImpl<'tcx, C> {
+impl<'tcx, C: QueryCache> QueryState<'tcx, C> {
     pub fn iter_results<R>(
         &self,
         f: impl for<'a> FnOnce(
@@ -130,9 +128,9 @@ impl<'tcx, C: QueryCache> QueryStateImpl<'tcx, C> {
     }
 }
 
-impl<'tcx, C: QueryCache> Default for QueryStateImpl<'tcx, C> {
-    fn default() -> QueryStateImpl<'tcx, C> {
-        QueryStateImpl {
+impl<'tcx, C: QueryCache> Default for QueryState<'tcx, C> {
+    fn default() -> QueryState<'tcx, C> {
+        QueryState {
             cache: C::default(),
             shards: Default::default(),
             #[cfg(debug_assertions)]
@@ -156,7 +154,7 @@ where
     C::Key: Eq + Hash + Clone + Debug,
     C::Value: Clone,
 {
-    state: &'tcx QueryStateImpl<'tcx, C>,
+    state: &'tcx QueryState<'tcx, C>,
     key: C::Key,
     id: QueryJobId,
 }
@@ -482,7 +480,7 @@ impl<'tcx> TyCtxt<'tcx> {
     #[inline(always)]
     fn try_get_cached<C, R, OnHit, OnMiss>(
         self,
-        state: &'tcx QueryStateImpl<'tcx, C>,
+        state: &'tcx QueryState<'tcx, C>,
         key: C::Key,
         // `on_hit` can be called while holding a lock to the query cache
         on_hit: OnHit,
@@ -979,7 +977,7 @@ macro_rules! define_queries_inner {
             type Cache = query_storage!([$($modifiers)*][$K, $V]);
 
             #[inline(always)]
-            fn query_state<'a>(tcx: TyCtxt<$tcx>) -> &'a QueryState<$tcx, Self> {
+            fn query_state<'a>(tcx: TyCtxt<$tcx>) -> &'a QueryState<$tcx, Self::Cache> {
                 &tcx.queries.$name
             }
 
@@ -1131,7 +1129,10 @@ macro_rules! define_queries_struct {
             providers: IndexVec<CrateNum, Providers<$tcx>>,
             fallback_extern_providers: Box<Providers<$tcx>>,
 
-            $($(#[$attr])*  $name: QueryState<$tcx, queries::$name<$tcx>>,)*
+            $($(#[$attr])*  $name: QueryState<
+                $tcx,
+                <queries::$name<$tcx> as QueryAccessors<'tcx>>::Cache,
+            >,)*
         }
 
         impl<$tcx> Queries<$tcx> {
diff --git a/src/librustc/ty/query/profiling_support.rs b/src/librustc/ty/query/profiling_support.rs
index 256bd86a3de..58ace917786 100644
--- a/src/librustc/ty/query/profiling_support.rs
+++ b/src/librustc/ty/query/profiling_support.rs
@@ -1,7 +1,7 @@
 use crate::hir::map::definitions::DefPathData;
 use crate::ty::context::TyCtxt;
 use crate::ty::query::caches::QueryCache;
-use crate::ty::query::plumbing::QueryStateImpl;
+use crate::ty::query::plumbing::QueryState;
 use measureme::{StringComponent, StringId};
 use rustc_data_structures::fx::FxHashMap;
 use rustc_data_structures::profiling::SelfProfiler;
@@ -160,7 +160,7 @@ where
 pub(super) fn alloc_self_profile_query_strings_for_query_cache<'tcx, C>(
     tcx: TyCtxt<'tcx>,
     query_name: &'static str,
-    query_state: &QueryStateImpl<'tcx, C>,
+    query_state: &QueryState<'tcx, C>,
     string_cache: &mut QueryKeyStringCache,
 ) where
     C: QueryCache,
diff --git a/src/librustc/ty/query/stats.rs b/src/librustc/ty/query/stats.rs
index 20894a2a5d1..527bb46c908 100644
--- a/src/librustc/ty/query/stats.rs
+++ b/src/librustc/ty/query/stats.rs
@@ -1,6 +1,6 @@
 use crate::ty::query::caches::QueryCache;
 use crate::ty::query::config::QueryAccessors;
-use crate::ty::query::plumbing::QueryStateImpl;
+use crate::ty::query::plumbing::QueryState;
 use crate::ty::query::queries;
 use crate::ty::TyCtxt;
 use rustc_hir::def_id::{DefId, LOCAL_CRATE};
@@ -38,7 +38,7 @@ struct QueryStats {
     local_def_id_keys: Option<usize>,
 }
 
-fn stats<'tcx, C: QueryCache>(name: &'static str, map: &QueryStateImpl<'tcx, C>) -> QueryStats {
+fn stats<'tcx, C: QueryCache>(name: &'static str, map: &QueryState<'tcx, C>) -> QueryStats {
     let mut stats = QueryStats {
         name,
         #[cfg(debug_assertions)]