@@ -247,7 +247,8 @@ where
247247 return TryGetJob :: Cycle ( Q :: handle_cycle_error ( tcx, cycle) ) ;
248248 }
249249
250- let cached = tcx. try_get_cached (
250+ let cached = try_get_cached (
251+ tcx,
251252 Q :: query_state ( tcx) ,
252253 ( * key) . clone ( ) ,
253254 |value, index| ( value. clone ( ) , index) ,
@@ -500,32 +501,34 @@ impl<'tcx> TyCtxt<'tcx> {
500501
501502 eprintln ! ( "end of query stack" ) ;
502503 }
504+ }
503505
504506 /// Checks if the query is already computed and in the cache.
505507 /// It returns the shard index and a lock guard to the shard,
506508 /// which will be used if the query is not in the cache and we need
507509 /// to compute it.
508510 #[ inline( always) ]
509- fn try_get_cached < C , R , OnHit , OnMiss > (
510- self ,
511- state : & ' tcx QueryState < TyCtxt < ' tcx > , C > ,
511+ fn try_get_cached < CTX , C , R , OnHit , OnMiss > (
512+ tcx : CTX ,
513+ state : & QueryState < CTX , C > ,
512514 key : C :: Key ,
513515 // `on_hit` can be called while holding a lock to the query cache
514516 on_hit : OnHit ,
515517 on_miss : OnMiss ,
516518 ) -> R
517519 where
518- C : QueryCache < TyCtxt < ' tcx > > ,
520+ C : QueryCache < CTX > ,
521+ CTX : QueryContext ,
519522 OnHit : FnOnce ( & C :: Value , DepNodeIndex ) -> R ,
520- OnMiss : FnOnce ( C :: Key , QueryLookup < ' _ , TyCtxt < ' tcx > , C :: Key , C :: Sharded > ) -> R ,
523+ OnMiss : FnOnce ( C :: Key , QueryLookup < ' _ , CTX , C :: Key , C :: Sharded > ) -> R ,
521524 {
522525 state. cache . lookup (
523526 state,
524- QueryStateShard :: < TyCtxt < ' tcx > , C :: Key , C :: Sharded > :: get_cache,
527+ QueryStateShard :: < CTX , C :: Key , C :: Sharded > :: get_cache,
525528 key,
526529 |value, index| {
527- if unlikely ! ( self . prof . enabled( ) ) {
528- self . prof . query_cache_hit ( index. into ( ) ) ;
530+ if unlikely ! ( tcx . profiler ( ) . enabled( ) ) {
531+ tcx . profiler ( ) . query_cache_hit ( index. into ( ) ) ;
529532 }
530533 #[ cfg( debug_assertions) ]
531534 {
@@ -537,6 +540,7 @@ impl<'tcx> TyCtxt<'tcx> {
537540 )
538541 }
539542
543+ impl < ' tcx > TyCtxt < ' tcx > {
540544 #[ inline( never) ]
541545 pub ( super ) fn get_query < Q : QueryDescription < TyCtxt < ' tcx > > + ' tcx > (
542546 self ,
@@ -545,7 +549,8 @@ impl<'tcx> TyCtxt<'tcx> {
545549 ) -> Q :: Value {
546550 debug ! ( "ty::query::get_query<{}>(key={:?}, span={:?})" , Q :: NAME , key, span) ;
547551
548- self . try_get_cached (
552+ try_get_cached (
553+ self ,
549554 Q :: query_state ( self ) ,
550555 key,
551556 |value, index| {
@@ -819,7 +824,8 @@ impl<'tcx> TyCtxt<'tcx> {
819824 // We may be concurrently trying both execute and force a query.
820825 // Ensure that only one of them runs the query.
821826
822- self . try_get_cached (
827+ try_get_cached (
828+ self ,
823829 Q :: query_state ( self ) ,
824830 key,
825831 |_, _| {
0 commit comments