Skip to content

Commit 5557407

Browse files
committed
Remove QueryState type alias.
1 parent 3abd475 commit 5557407

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(
@@ -130,9 +128,9 @@ impl<'tcx, C: QueryCache> QueryStateImpl<'tcx, C> {
130128
}
131129
}
132130

133-
impl<'tcx, C: QueryCache> Default for QueryStateImpl<'tcx, C> {
134-
fn default() -> QueryStateImpl<'tcx, C> {
135-
QueryStateImpl {
131+
impl<'tcx, C: QueryCache> Default for QueryState<'tcx, C> {
132+
fn default() -> QueryState<'tcx, C> {
133+
QueryState {
136134
cache: C::default(),
137135
shards: Default::default(),
138136
#[cfg(debug_assertions)]
@@ -156,7 +154,7 @@ where
156154
C::Key: Eq + Hash + Clone + Debug,
157155
C::Value: Clone,
158156
{
159-
state: &'tcx QueryStateImpl<'tcx, C>,
157+
state: &'tcx QueryState<'tcx, C>,
160158
key: C::Key,
161159
id: QueryJobId,
162160
}
@@ -482,7 +480,7 @@ impl<'tcx> TyCtxt<'tcx> {
482480
#[inline(always)]
483481
fn try_get_cached<C, R, OnHit, OnMiss>(
484482
self,
485-
state: &'tcx QueryStateImpl<'tcx, C>,
483+
state: &'tcx QueryState<'tcx, C>,
486484
key: C::Key,
487485
// `on_hit` can be called while holding a lock to the query cache
488486
on_hit: OnHit,
@@ -979,7 +977,7 @@ macro_rules! define_queries_inner {
979977
type Cache = query_storage!([$($modifiers)*][$K, $V]);
980978

981979
#[inline(always)]
982-
fn query_state<'a>(tcx: TyCtxt<$tcx>) -> &'a QueryState<$tcx, Self> {
980+
fn query_state<'a>(tcx: TyCtxt<$tcx>) -> &'a QueryState<$tcx, Self::Cache> {
983981
&tcx.queries.$name
984982
}
985983

@@ -1131,7 +1129,10 @@ macro_rules! define_queries_struct {
11311129
providers: IndexVec<CrateNum, Providers<$tcx>>,
11321130
fallback_extern_providers: Box<Providers<$tcx>>,
11331131

1134-
$($(#[$attr])* $name: QueryState<$tcx, queries::$name<$tcx>>,)*
1132+
$($(#[$attr])* $name: QueryState<
1133+
$tcx,
1134+
<queries::$name<$tcx> as QueryAccessors<'tcx>>::Cache,
1135+
>,)*
11351136
}
11361137

11371138
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)