Skip to content

Commit 5dc7c2e

Browse files
committed
Remove Q parameter from try_get_cached.
1 parent fa0794d commit 5dc7c2e

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/librustc/ty/query/plumbing.rs

+13-11
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,8 @@ where
236236
return TryGetJob::Cycle(Q::handle_cycle_error(tcx, cycle));
237237
}
238238

239-
let cached = tcx.try_get_cached::<Q, _, _, _>(
239+
let cached = tcx.try_get_cached(
240+
Q::query_state(tcx),
240241
(*key).clone(),
241242
|value, index| (value.clone(), index),
242243
|_, _| panic!("value must be in cache after waiting"),
@@ -460,23 +461,22 @@ impl<'tcx> TyCtxt<'tcx> {
460461
/// which will be used if the query is not in the cache and we need
461462
/// to compute it.
462463
#[inline(always)]
463-
fn try_get_cached<Q, R, OnHit, OnMiss>(
464+
fn try_get_cached<K, V, C, R, OnHit, OnMiss>(
464465
self,
465-
key: Q::Key,
466+
state: &'tcx QueryStateImpl<'tcx, K, V, C>,
467+
key: K,
466468
// `on_hit` can be called while holding a lock to the query cache
467469
on_hit: OnHit,
468470
on_miss: OnMiss,
469471
) -> R
470472
where
471-
Q: QueryDescription<'tcx> + 'tcx,
472-
OnHit: FnOnce(&Q::Value, DepNodeIndex) -> R,
473-
OnMiss: FnOnce(Q::Key, QueryLookup<'tcx, Q>) -> R,
473+
C: QueryCache<K, V>,
474+
OnHit: FnOnce(&V, DepNodeIndex) -> R,
475+
OnMiss: FnOnce(K, QueryLookupImpl<'tcx, QueryStateShardImpl<'tcx, K, C::Sharded>>) -> R,
474476
{
475-
let state = Q::query_state(self);
476-
477477
state.cache.lookup(
478478
state,
479-
QueryStateShard::<Q>::get_cache,
479+
QueryStateShardImpl::<K, C::Sharded>::get_cache,
480480
key,
481481
|value, index| {
482482
if unlikely!(self.prof.enabled()) {
@@ -500,7 +500,8 @@ impl<'tcx> TyCtxt<'tcx> {
500500
) -> Q::Value {
501501
debug!("ty::query::get_query<{}>(key={:?}, span={:?})", Q::NAME, key, span);
502502

503-
self.try_get_cached::<Q, _, _, _>(
503+
self.try_get_cached(
504+
Q::query_state(self),
504505
key,
505506
|value, index| {
506507
self.dep_graph.read_index(index);
@@ -770,7 +771,8 @@ impl<'tcx> TyCtxt<'tcx> {
770771
// We may be concurrently trying both execute and force a query.
771772
// Ensure that only one of them runs the query.
772773

773-
self.try_get_cached::<Q, _, _, _>(
774+
self.try_get_cached(
775+
Q::query_state(self),
774776
key,
775777
|_, _| {
776778
// Cache hit, do nothing

0 commit comments

Comments
 (0)