Skip to content

Commit 858d8fa

Browse files
committed
Remove QueryState type alias.
1 parent 18ed6b7 commit 858d8fa

File tree

5 files changed

+22
-21
lines changed

5 files changed

+22
-21
lines changed

src/librustc/ty/query/caches.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::dep_graph::DepNodeIndex;
2-
use crate::ty::query::plumbing::{QueryLookup, QueryStateImpl, QueryStateShard};
2+
use crate::ty::query::plumbing::{QueryLookup, QueryState, QueryStateShard};
33
use crate::ty::TyCtxt;
44

55
use rustc_data_structures::fx::FxHashMap;
@@ -23,7 +23,7 @@ pub(crate) trait QueryCache: Default {
2323
/// to compute it.
2424
fn lookup<'tcx, R, GetCache, OnHit, OnMiss>(
2525
&self,
26-
state: &'tcx QueryStateImpl<'tcx, Self>,
26+
state: &'tcx QueryState<'tcx, Self>,
2727
get_cache: GetCache,
2828
key: Self::Key,
2929
// `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> {
7878
#[inline(always)]
7979
fn lookup<'tcx, R, GetCache, OnHit, OnMiss>(
8080
&self,
81-
state: &'tcx QueryStateImpl<'tcx, Self>,
81+
state: &'tcx QueryState<'tcx, Self>,
8282
get_cache: GetCache,
8383
key: K,
8484
on_hit: OnHit,

src/librustc/ty/query/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub(crate) trait QueryAccessors<'tcx>: QueryConfig<'tcx> {
3333
type Cache: QueryCache<Key = Self::Key, Value = Self::Value>;
3434

3535
// Don't use this method to access query results, instead use the methods on TyCtxt
36-
fn query_state<'a>(tcx: TyCtxt<'tcx>) -> &'a QueryState<'tcx, Self>;
36+
fn query_state<'a>(tcx: TyCtxt<'tcx>) -> &'a QueryState<'tcx, Self::Cache>;
3737

3838
fn to_dep_node(tcx: TyCtxt<'tcx>, key: &Self::Key) -> DepNode;
3939

src/librustc/ty/query/plumbing.rs

+14-13
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
use crate::dep_graph::{DepKind, DepNode, DepNodeIndex, SerializedDepNodeIndex};
66
use crate::ty::query::caches::QueryCache;
7-
use crate::ty::query::config::{QueryAccessors, QueryDescription};
7+
use crate::ty::query::config::QueryDescription;
88
use crate::ty::query::job::{QueryInfo, QueryJob, QueryJobId, QueryJobInfo, QueryShardJobId};
99
use crate::ty::query::Query;
1010
use crate::ty::tls;
@@ -49,16 +49,14 @@ impl<'tcx, K, C: Default> Default for QueryStateShard<'tcx, K, C> {
4949
}
5050
}
5151

52-
pub(crate) type QueryState<'tcx, Q> = QueryStateImpl<'tcx, <Q as QueryAccessors<'tcx>>::Cache>;
53-
54-
pub(crate) struct QueryStateImpl<'tcx, C: QueryCache> {
52+
pub(crate) struct QueryState<'tcx, C: QueryCache> {
5553
pub(super) cache: C,
5654
pub(super) shards: Sharded<QueryStateShard<'tcx, C::Key, C::Sharded>>,
5755
#[cfg(debug_assertions)]
5856
pub(super) cache_hits: AtomicUsize,
5957
}
6058

61-
impl<'tcx, C: QueryCache> QueryStateImpl<'tcx, C> {
59+
impl<'tcx, C: QueryCache> QueryState<'tcx, C> {
6260
pub(super) fn get_lookup<K2: Hash>(
6361
&'tcx self,
6462
key: &K2,
@@ -86,7 +84,7 @@ pub(super) enum QueryResult<'tcx> {
8684
Poisoned,
8785
}
8886

89-
impl<'tcx, C: QueryCache> QueryStateImpl<'tcx, C> {
87+
impl<'tcx, C: QueryCache> QueryState<'tcx, C> {
9088
pub fn iter_results<R>(
9189
&self,
9290
f: impl for<'a> FnOnce(
@@ -131,9 +129,9 @@ impl<'tcx, C: QueryCache> QueryStateImpl<'tcx, C> {
131129
}
132130
}
133131

134-
impl<'tcx, C: QueryCache> Default for QueryStateImpl<'tcx, C> {
135-
fn default() -> QueryStateImpl<'tcx, C> {
136-
QueryStateImpl {
132+
impl<'tcx, C: QueryCache> Default for QueryState<'tcx, C> {
133+
fn default() -> QueryState<'tcx, C> {
134+
QueryState {
137135
cache: C::default(),
138136
shards: Default::default(),
139137
#[cfg(debug_assertions)]
@@ -157,7 +155,7 @@ where
157155
C::Key: Eq + Hash + Clone + Debug,
158156
C::Value: Clone,
159157
{
160-
state: &'tcx QueryStateImpl<'tcx, C>,
158+
state: &'tcx QueryState<'tcx, C>,
161159
key: C::Key,
162160
id: QueryJobId,
163161
}
@@ -478,7 +476,7 @@ impl<'tcx> TyCtxt<'tcx> {
478476
#[inline(always)]
479477
fn try_get_cached<C, R, OnHit, OnMiss>(
480478
self,
481-
state: &'tcx QueryStateImpl<'tcx, C>,
479+
state: &'tcx QueryState<'tcx, C>,
482480
key: C::Key,
483481
// `on_hit` can be called while holding a lock to the query cache
484482
on_hit: OnHit,
@@ -994,7 +992,7 @@ macro_rules! define_queries_inner {
994992
type Cache = query_storage!([$($modifiers)*][$K, $V]);
995993

996994
#[inline(always)]
997-
fn query_state<'a>(tcx: TyCtxt<$tcx>) -> &'a QueryState<$tcx, Self> {
995+
fn query_state<'a>(tcx: TyCtxt<$tcx>) -> &'a QueryState<$tcx, Self::Cache> {
998996
&tcx.queries.$name
999997
}
1000998

@@ -1139,7 +1137,10 @@ macro_rules! define_queries_struct {
11391137
providers: IndexVec<CrateNum, Providers<$tcx>>,
11401138
fallback_extern_providers: Box<Providers<$tcx>>,
11411139

1142-
$($(#[$attr])* $name: QueryState<$tcx, queries::$name<$tcx>>,)*
1140+
$($(#[$attr])* $name: QueryState<
1141+
$tcx,
1142+
<queries::$name<$tcx> as QueryAccessors<'tcx>>::Cache,
1143+
>,)*
11431144
}
11441145

11451146
impl<$tcx> Queries<$tcx> {

src/librustc/ty/query/profiling_support.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::hir::map::definitions::DefPathData;
22
use crate::ty::context::TyCtxt;
33
use crate::ty::query::caches::QueryCache;
4-
use crate::ty::query::plumbing::QueryStateImpl;
4+
use crate::ty::query::plumbing::QueryState;
55
use measureme::{StringComponent, StringId};
66
use rustc_data_structures::fx::FxHashMap;
77
use rustc_data_structures::profiling::SelfProfiler;
@@ -160,7 +160,7 @@ where
160160
pub(super) fn alloc_self_profile_query_strings_for_query_cache<'tcx, C>(
161161
tcx: TyCtxt<'tcx>,
162162
query_name: &'static str,
163-
query_state: &QueryStateImpl<'tcx, C>,
163+
query_state: &QueryState<'tcx, C>,
164164
string_cache: &mut QueryKeyStringCache,
165165
) where
166166
C: QueryCache,

src/librustc/ty/query/stats.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::ty::query::caches::QueryCache;
22
use crate::ty::query::config::QueryAccessors;
3-
use crate::ty::query::plumbing::QueryStateImpl;
3+
use crate::ty::query::plumbing::QueryState;
44
use crate::ty::query::queries;
55
use crate::ty::TyCtxt;
66
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
@@ -38,7 +38,7 @@ struct QueryStats {
3838
local_def_id_keys: Option<usize>,
3939
}
4040

41-
fn stats<'tcx, C: QueryCache>(name: &'static str, map: &QueryStateImpl<'tcx, C>) -> QueryStats {
41+
fn stats<'tcx, C: QueryCache>(name: &'static str, map: &QueryState<'tcx, C>) -> QueryStats {
4242
let mut stats = QueryStats {
4343
name,
4444
#[cfg(debug_assertions)]

0 commit comments

Comments
 (0)