Remove Q parameter from QueryCache::lookup.
This commit is contained in:
parent
a0f57e24e3
commit
fa02dca428
2 changed files with 14 additions and 13 deletions
|
|
@ -1,6 +1,5 @@
|
|||
use crate::dep_graph::DepNodeIndex;
|
||||
use crate::ty::query::config::QueryAccessors;
|
||||
use crate::ty::query::plumbing::{QueryLookup, QueryState, QueryStateShard};
|
||||
use crate::ty::query::plumbing::{QueryLookupImpl, QueryStateImpl, QueryStateShardImpl};
|
||||
use crate::ty::TyCtxt;
|
||||
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
|
|
@ -19,9 +18,9 @@ pub(crate) trait QueryCache<K, V>: 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<'tcx, R, GetCache, OnHit, OnMiss, Q>(
|
||||
fn lookup<'tcx, R, GetCache, OnHit, OnMiss>(
|
||||
&self,
|
||||
state: &'tcx QueryState<'tcx, Q>,
|
||||
state: &'tcx QueryStateImpl<'tcx, K, V, Self>,
|
||||
get_cache: GetCache,
|
||||
key: K,
|
||||
// `on_hit` can be called while holding a lock to the query state shard.
|
||||
|
|
@ -29,10 +28,11 @@ pub(crate) trait QueryCache<K, V>: Default {
|
|||
on_miss: OnMiss,
|
||||
) -> R
|
||||
where
|
||||
Q: QueryAccessors<'tcx>,
|
||||
GetCache: for<'a> Fn(&'a mut QueryStateShard<'tcx, Q>) -> &'a mut Self::Sharded,
|
||||
GetCache: for<'a> Fn(
|
||||
&'a mut QueryStateShardImpl<'tcx, K, Self::Sharded>,
|
||||
) -> &'a mut Self::Sharded,
|
||||
OnHit: FnOnce(&V, DepNodeIndex) -> R,
|
||||
OnMiss: FnOnce(K, QueryLookup<'tcx, Q>) -> R;
|
||||
OnMiss: FnOnce(K, QueryLookupImpl<'tcx, QueryStateShardImpl<'tcx, K, Self::Sharded>>) -> R;
|
||||
|
||||
fn complete(
|
||||
&self,
|
||||
|
|
@ -64,19 +64,20 @@ impl<K: Eq + Hash, V: Clone> QueryCache<K, V> for DefaultCache {
|
|||
type Sharded = FxHashMap<K, (V, DepNodeIndex)>;
|
||||
|
||||
#[inline(always)]
|
||||
fn lookup<'tcx, R, GetCache, OnHit, OnMiss, Q>(
|
||||
fn lookup<'tcx, R, GetCache, OnHit, OnMiss>(
|
||||
&self,
|
||||
state: &'tcx QueryState<'tcx, Q>,
|
||||
state: &'tcx QueryStateImpl<'tcx, K, V, Self>,
|
||||
get_cache: GetCache,
|
||||
key: K,
|
||||
on_hit: OnHit,
|
||||
on_miss: OnMiss,
|
||||
) -> R
|
||||
where
|
||||
Q: QueryAccessors<'tcx>,
|
||||
GetCache: for<'a> Fn(&'a mut QueryStateShard<'tcx, Q>) -> &'a mut Self::Sharded,
|
||||
GetCache: for<'a> Fn(
|
||||
&'a mut QueryStateShardImpl<'tcx, K, Self::Sharded>,
|
||||
) -> &'a mut Self::Sharded,
|
||||
OnHit: FnOnce(&V, DepNodeIndex) -> R,
|
||||
OnMiss: FnOnce(K, QueryLookup<'tcx, Q>) -> R,
|
||||
OnMiss: FnOnce(K, QueryLookupImpl<'tcx, QueryStateShardImpl<'tcx, K, Self::Sharded>>) -> R,
|
||||
{
|
||||
let mut lookup = state.get_lookup(&key);
|
||||
let lock = &mut *lookup.lock;
|
||||
|
|
|
|||
|
|
@ -449,7 +449,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
{
|
||||
let state = Q::query_state(self);
|
||||
|
||||
state.cache.lookup::<_, _, _, _, Q>(
|
||||
state.cache.lookup(
|
||||
state,
|
||||
QueryStateShard::<Q>::get_cache,
|
||||
key,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue