@@ -247,7 +247,8 @@ where
247
247
return TryGetJob :: Cycle ( Q :: handle_cycle_error ( tcx, cycle) ) ;
248
248
}
249
249
250
- let cached = tcx. try_get_cached (
250
+ let cached = try_get_cached (
251
+ tcx,
251
252
Q :: query_state ( tcx) ,
252
253
( * key) . clone ( ) ,
253
254
|value, index| ( value. clone ( ) , index) ,
@@ -500,32 +501,34 @@ impl<'tcx> TyCtxt<'tcx> {
500
501
501
502
eprintln ! ( "end of query stack" ) ;
502
503
}
504
+ }
503
505
504
506
/// Checks if the query is already computed and in the cache.
505
507
/// It returns the shard index and a lock guard to the shard,
506
508
/// which will be used if the query is not in the cache and we need
507
509
/// to compute it.
508
510
#[ 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 > ,
512
514
key : C :: Key ,
513
515
// `on_hit` can be called while holding a lock to the query cache
514
516
on_hit : OnHit ,
515
517
on_miss : OnMiss ,
516
518
) -> R
517
519
where
518
- C : QueryCache < TyCtxt < ' tcx > > ,
520
+ C : QueryCache < CTX > ,
521
+ CTX : QueryContext ,
519
522
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 ,
521
524
{
522
525
state. cache . lookup (
523
526
state,
524
- QueryStateShard :: < TyCtxt < ' tcx > , C :: Key , C :: Sharded > :: get_cache,
527
+ QueryStateShard :: < CTX , C :: Key , C :: Sharded > :: get_cache,
525
528
key,
526
529
|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 ( ) ) ;
529
532
}
530
533
#[ cfg( debug_assertions) ]
531
534
{
@@ -537,6 +540,7 @@ impl<'tcx> TyCtxt<'tcx> {
537
540
)
538
541
}
539
542
543
+ impl < ' tcx > TyCtxt < ' tcx > {
540
544
#[ inline( never) ]
541
545
pub ( super ) fn get_query < Q : QueryDescription < TyCtxt < ' tcx > > + ' tcx > (
542
546
self ,
@@ -545,7 +549,8 @@ impl<'tcx> TyCtxt<'tcx> {
545
549
) -> Q :: Value {
546
550
debug ! ( "ty::query::get_query<{}>(key={:?}, span={:?})" , Q :: NAME , key, span) ;
547
551
548
- self . try_get_cached (
552
+ try_get_cached (
553
+ self ,
549
554
Q :: query_state ( self ) ,
550
555
key,
551
556
|value, index| {
@@ -819,7 +824,8 @@ impl<'tcx> TyCtxt<'tcx> {
819
824
// We may be concurrently trying both execute and force a query.
820
825
// Ensure that only one of them runs the query.
821
826
822
- self . try_get_cached (
827
+ try_get_cached (
828
+ self ,
823
829
Q :: query_state ( self ) ,
824
830
key,
825
831
|_, _| {
0 commit comments