Skip to content

Commit fa06cfd

Browse files
committed
Move generics on QueryCache.
1 parent 0e8b59a commit fa06cfd

File tree

6 files changed

+23
-23
lines changed

6 files changed

+23
-23
lines changed

src/librustc/ty/query/plumbing.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ macro_rules! is_eval_always {
208208

209209
macro_rules! query_storage {
210210
(<$tcx:tt>[][$K:ty, $V:ty]) => {
211-
<<$K as Key>::CacheSelector as CacheSelector<TyCtxt<$tcx>, $K, $V>>::Cache
211+
<<$K as Key>::CacheSelector as CacheSelector<$K, $V>>::Cache
212212
};
213213
(<$tcx:tt>[storage($ty:ty) $($rest:tt)*][$K:ty, $V:ty]) => {
214214
$ty

src/librustc/ty/query/profiling_support.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ pub(super) fn alloc_self_profile_query_strings_for_query_cache<'tcx, C>(
163163
query_state: &QueryState<TyCtxt<'tcx>, C>,
164164
string_cache: &mut QueryKeyStringCache,
165165
) where
166-
C: QueryCache<TyCtxt<'tcx>>,
166+
C: QueryCache,
167167
C::Key: Debug + Clone,
168168
{
169169
tcx.prof.with_profiler(|profiler| {

src/librustc/ty/query/stats.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ struct QueryStats {
3838
local_def_id_keys: Option<usize>,
3939
}
4040

41-
fn stats<CTX: QueryContext, C: QueryCache<CTX>>(
41+
fn stats<CTX: QueryContext, C: QueryCache>(
4242
name: &'static str,
4343
map: &QueryState<CTX, C>,
4444
) -> QueryStats {

src/librustc_query_system/query/caches.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ use std::default::Default;
88
use std::hash::Hash;
99
use std::marker::PhantomData;
1010

11-
pub trait CacheSelector<CTX: QueryContext, K: Hash, V> {
12-
type Cache: QueryCache<CTX, Key = K, Value = V>;
11+
pub trait CacheSelector<K: Hash, V> {
12+
type Cache: QueryCache<Key = K, Value = V>;
1313
}
1414

15-
pub trait QueryCache<CTX: QueryContext>: Default {
15+
pub trait QueryCache: Default {
1616
type Key: Hash;
1717
type Value;
1818
type Sharded: Default;
@@ -21,7 +21,7 @@ pub trait QueryCache<CTX: QueryContext>: Default {
2121
/// It returns the shard index and a lock guard to the shard,
2222
/// which will be used if the query is not in the cache and we need
2323
/// to compute it.
24-
fn lookup<R, OnHit, OnMiss>(
24+
fn lookup<CTX: QueryContext, R, OnHit, OnMiss>(
2525
&self,
2626
state: &QueryState<CTX, Self>,
2727
key: Self::Key,
@@ -33,7 +33,7 @@ pub trait QueryCache<CTX: QueryContext>: Default {
3333
OnHit: FnOnce(&Self::Value, DepNodeIndex) -> R,
3434
OnMiss: FnOnce(Self::Key, QueryLookup<'_, CTX, Self::Key, Self::Sharded>) -> R;
3535

36-
fn complete(
36+
fn complete<CTX: QueryContext>(
3737
&self,
3838
tcx: CTX,
3939
lock_sharded_storage: &mut Self::Sharded,
@@ -54,7 +54,7 @@ pub trait QueryCache<CTX: QueryContext>: Default {
5454

5555
pub struct DefaultCacheSelector;
5656

57-
impl<CTX: QueryContext, K: Eq + Hash, V: Clone> CacheSelector<CTX, K, V> for DefaultCacheSelector {
57+
impl<K: Eq + Hash, V: Clone> CacheSelector<K, V> for DefaultCacheSelector {
5858
type Cache = DefaultCache<K, V>;
5959
}
6060

@@ -66,13 +66,13 @@ impl<K, V> Default for DefaultCache<K, V> {
6666
}
6767
}
6868

69-
impl<CTX: QueryContext, K: Eq + Hash, V: Clone> QueryCache<CTX> for DefaultCache<K, V> {
69+
impl<K: Eq + Hash, V: Clone> QueryCache for DefaultCache<K, V> {
7070
type Key = K;
7171
type Value = V;
7272
type Sharded = FxHashMap<K, (V, DepNodeIndex)>;
7373

7474
#[inline(always)]
75-
fn lookup<R, OnHit, OnMiss>(
75+
fn lookup<CTX: QueryContext, R, OnHit, OnMiss>(
7676
&self,
7777
state: &QueryState<CTX, Self>,
7878
key: K,
@@ -92,7 +92,7 @@ impl<CTX: QueryContext, K: Eq + Hash, V: Clone> QueryCache<CTX> for DefaultCache
9292
}
9393

9494
#[inline]
95-
fn complete(
95+
fn complete<CTX: QueryContext>(
9696
&self,
9797
_: CTX,
9898
lock_sharded_storage: &mut Self::Sharded,

src/librustc_query_system/query/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub trait QueryAccessors<CTX: QueryContext>: QueryConfig<CTX> {
6363
const EVAL_ALWAYS: bool;
6464
const DEP_KIND: CTX::DepKind;
6565

66-
type Cache: QueryCache<CTX, Key = Self::Key, Value = Self::Value>;
66+
type Cache: QueryCache<Key = Self::Key, Value = Self::Value>;
6767

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

src/librustc_query_system/query/plumbing.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ impl<CTX: QueryContext, K, C: Default> Default for QueryStateShard<CTX, K, C> {
4242
}
4343
}
4444

45-
pub struct QueryState<CTX: QueryContext, C: QueryCache<CTX>> {
45+
pub struct QueryState<CTX: QueryContext, C: QueryCache> {
4646
cache: C,
4747
shards: Sharded<QueryStateShard<CTX, C::Key, C::Sharded>>,
4848
#[cfg(debug_assertions)]
4949
pub cache_hits: AtomicUsize,
5050
}
5151

52-
impl<CTX: QueryContext, C: QueryCache<CTX>> QueryState<CTX, C> {
52+
impl<CTX: QueryContext, C: QueryCache> QueryState<CTX, C> {
5353
pub(super) fn get_lookup<'tcx>(
5454
&'tcx self,
5555
key: &C::Key,
@@ -77,7 +77,7 @@ enum QueryResult<CTX: QueryContext> {
7777
Poisoned,
7878
}
7979

80-
impl<CTX: QueryContext, C: QueryCache<CTX>> QueryState<CTX, C> {
80+
impl<CTX: QueryContext, C: QueryCache> QueryState<CTX, C> {
8181
pub fn iter_results<R>(
8282
&self,
8383
f: impl for<'a> FnOnce(
@@ -122,7 +122,7 @@ impl<CTX: QueryContext, C: QueryCache<CTX>> QueryState<CTX, C> {
122122
}
123123
}
124124

125-
impl<CTX: QueryContext, C: QueryCache<CTX>> Default for QueryState<CTX, C> {
125+
impl<CTX: QueryContext, C: QueryCache> Default for QueryState<CTX, C> {
126126
fn default() -> QueryState<CTX, C> {
127127
QueryState {
128128
cache: C::default(),
@@ -144,7 +144,7 @@ pub struct QueryLookup<'tcx, CTX: QueryContext, K, C> {
144144
/// This will poison the relevant query if dropped.
145145
struct JobOwner<'tcx, CTX: QueryContext, C>
146146
where
147-
C: QueryCache<CTX>,
147+
C: QueryCache,
148148
C::Key: Eq + Hash + Clone + Debug,
149149
C::Value: Clone,
150150
{
@@ -155,7 +155,7 @@ where
155155

156156
impl<'tcx, CTX: QueryContext, C> JobOwner<'tcx, CTX, C>
157157
where
158-
C: QueryCache<CTX>,
158+
C: QueryCache,
159159
C::Key: Eq + Hash + Clone + Debug,
160160
C::Value: Clone,
161161
{
@@ -292,7 +292,7 @@ where
292292
(result, diagnostics.into_inner())
293293
}
294294

295-
impl<'tcx, CTX: QueryContext, C: QueryCache<CTX>> Drop for JobOwner<'tcx, CTX, C>
295+
impl<'tcx, CTX: QueryContext, C: QueryCache> Drop for JobOwner<'tcx, CTX, C>
296296
where
297297
C::Key: Eq + Hash + Clone + Debug,
298298
C::Value: Clone,
@@ -326,7 +326,7 @@ pub struct CycleError<Q> {
326326
}
327327

328328
/// The result of `try_start`.
329-
enum TryGetJob<'tcx, CTX: QueryContext, C: QueryCache<CTX>>
329+
enum TryGetJob<'tcx, CTX: QueryContext, C: QueryCache>
330330
where
331331
C::Key: Eq + Hash + Clone + Debug,
332332
C::Value: Clone,
@@ -358,7 +358,7 @@ fn try_get_cached<CTX, C, R, OnHit, OnMiss>(
358358
on_miss: OnMiss,
359359
) -> R
360360
where
361-
C: QueryCache<CTX>,
361+
C: QueryCache,
362362
CTX: QueryContext,
363363
OnHit: FnOnce(&C::Value, DepNodeIndex) -> R,
364364
OnMiss: FnOnce(C::Key, QueryLookup<'_, CTX, C::Key, C::Sharded>) -> R,
@@ -385,7 +385,7 @@ fn try_execute_query<Q, CTX>(
385385
tcx: CTX,
386386
span: Span,
387387
key: Q::Key,
388-
lookup: QueryLookup<'_, CTX, Q::Key, <Q::Cache as QueryCache<CTX>>::Sharded>,
388+
lookup: QueryLookup<'_, CTX, Q::Key, <Q::Cache as QueryCache>::Sharded>,
389389
) -> Q::Value
390390
where
391391
Q: QueryDescription<CTX>,

0 commit comments

Comments
 (0)