macro_rules! query_storage {
(<$tcx:tt>[][$K:ty, $V:ty]) => {
- <<$K as Key>::CacheSelector as CacheSelector<TyCtxt<$tcx>, $K, $V>>::Cache
+ <<$K as Key>::CacheSelector as CacheSelector<$K, $V>>::Cache
};
(<$tcx:tt>[storage($ty:ty) $($rest:tt)*][$K:ty, $V:ty]) => {
$ty
query_state: &QueryState<TyCtxt<'tcx>, C>,
string_cache: &mut QueryKeyStringCache,
) where
- C: QueryCache<TyCtxt<'tcx>>,
+ C: QueryCache,
C::Key: Debug + Clone,
{
tcx.prof.with_profiler(|profiler| {
local_def_id_keys: Option<usize>,
}
-fn stats<CTX: QueryContext, C: QueryCache<CTX>>(
+fn stats<CTX: QueryContext, C: QueryCache>(
name: &'static str,
map: &QueryState<CTX, C>,
) -> QueryStats {
use std::hash::Hash;
use std::marker::PhantomData;
-pub trait CacheSelector<CTX: QueryContext, K: Hash, V> {
- type Cache: QueryCache<CTX, Key = K, Value = V>;
+pub trait CacheSelector<K: Hash, V> {
+ type Cache: QueryCache<Key = K, Value = V>;
}
-pub trait QueryCache<CTX: QueryContext>: Default {
+pub trait QueryCache: Default {
type Key: Hash;
type Value;
type Sharded: Default;
/// It returns the shard index and a lock guard to the shard,
/// which will be used if the query is not in the cache and we need
/// to compute it.
- fn lookup<R, OnHit, OnMiss>(
+ fn lookup<CTX: QueryContext, R, OnHit, OnMiss>(
&self,
state: &QueryState<CTX, Self>,
key: Self::Key,
OnHit: FnOnce(&Self::Value, DepNodeIndex) -> R,
OnMiss: FnOnce(Self::Key, QueryLookup<'_, CTX, Self::Key, Self::Sharded>) -> R;
- fn complete(
+ fn complete<CTX: QueryContext>(
&self,
tcx: CTX,
lock_sharded_storage: &mut Self::Sharded,
pub struct DefaultCacheSelector;
-impl<CTX: QueryContext, K: Eq + Hash, V: Clone> CacheSelector<CTX, K, V> for DefaultCacheSelector {
+impl<K: Eq + Hash, V: Clone> CacheSelector<K, V> for DefaultCacheSelector {
type Cache = DefaultCache<K, V>;
}
}
}
-impl<CTX: QueryContext, K: Eq + Hash, V: Clone> QueryCache<CTX> for DefaultCache<K, V> {
+impl<K: Eq + Hash, V: Clone> QueryCache for DefaultCache<K, V> {
type Key = K;
type Value = V;
type Sharded = FxHashMap<K, (V, DepNodeIndex)>;
#[inline(always)]
- fn lookup<R, OnHit, OnMiss>(
+ fn lookup<CTX: QueryContext, R, OnHit, OnMiss>(
&self,
state: &QueryState<CTX, Self>,
key: K,
}
#[inline]
- fn complete(
+ fn complete<CTX: QueryContext>(
&self,
_: CTX,
lock_sharded_storage: &mut Self::Sharded,
const EVAL_ALWAYS: bool;
const DEP_KIND: CTX::DepKind;
- type Cache: QueryCache<CTX, Key = Self::Key, Value = Self::Value>;
+ 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: CTX) -> &'a QueryState<CTX, Self::Cache>;
}
}
-pub struct QueryState<CTX: QueryContext, C: QueryCache<CTX>> {
+pub struct QueryState<CTX: QueryContext, C: QueryCache> {
cache: C,
shards: Sharded<QueryStateShard<CTX, C::Key, C::Sharded>>,
#[cfg(debug_assertions)]
pub cache_hits: AtomicUsize,
}
-impl<CTX: QueryContext, C: QueryCache<CTX>> QueryState<CTX, C> {
+impl<CTX: QueryContext, C: QueryCache> QueryState<CTX, C> {
pub(super) fn get_lookup<'tcx>(
&'tcx self,
key: &C::Key,
Poisoned,
}
-impl<CTX: QueryContext, C: QueryCache<CTX>> QueryState<CTX, C> {
+impl<CTX: QueryContext, C: QueryCache> QueryState<CTX, C> {
pub fn iter_results<R>(
&self,
f: impl for<'a> FnOnce(
}
}
-impl<CTX: QueryContext, C: QueryCache<CTX>> Default for QueryState<CTX, C> {
+impl<CTX: QueryContext, C: QueryCache> Default for QueryState<CTX, C> {
fn default() -> QueryState<CTX, C> {
QueryState {
cache: C::default(),
/// This will poison the relevant query if dropped.
struct JobOwner<'tcx, CTX: QueryContext, C>
where
- C: QueryCache<CTX>,
+ C: QueryCache,
C::Key: Eq + Hash + Clone + Debug,
C::Value: Clone,
{
impl<'tcx, CTX: QueryContext, C> JobOwner<'tcx, CTX, C>
where
- C: QueryCache<CTX>,
+ C: QueryCache,
C::Key: Eq + Hash + Clone + Debug,
C::Value: Clone,
{
(result, diagnostics.into_inner())
}
-impl<'tcx, CTX: QueryContext, C: QueryCache<CTX>> Drop for JobOwner<'tcx, CTX, C>
+impl<'tcx, CTX: QueryContext, C: QueryCache> Drop for JobOwner<'tcx, CTX, C>
where
C::Key: Eq + Hash + Clone + Debug,
C::Value: Clone,
}
/// The result of `try_start`.
-enum TryGetJob<'tcx, CTX: QueryContext, C: QueryCache<CTX>>
+enum TryGetJob<'tcx, CTX: QueryContext, C: QueryCache>
where
C::Key: Eq + Hash + Clone + Debug,
C::Value: Clone,
on_miss: OnMiss,
) -> R
where
- C: QueryCache<CTX>,
+ C: QueryCache,
CTX: QueryContext,
OnHit: FnOnce(&C::Value, DepNodeIndex) -> R,
OnMiss: FnOnce(C::Key, QueryLookup<'_, CTX, C::Key, C::Sharded>) -> R,
tcx: CTX,
span: Span,
key: Q::Key,
- lookup: QueryLookup<'_, CTX, Q::Key, <Q::Cache as QueryCache<CTX>>::Sharded>,
+ lookup: QueryLookup<'_, CTX, Q::Key, <Q::Cache as QueryCache>::Sharded>,
) -> Q::Value
where
Q: QueryDescription<CTX>,