Skip to content

Commit

Permalink
Remove Q parameter from QueryCache::lookup.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed Mar 16, 2020
1 parent a0f57e2 commit fa02dca
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
25 changes: 13 additions & 12 deletions src/librustc/ty/query/caches.rs
@@ -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;
Expand All @@ -19,20 +18,21 @@ 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.
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;

fn complete(
&self,
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/query/plumbing.rs
Expand Up @@ -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,
Expand Down

0 comments on commit fa02dca

Please sign in to comment.