@@ -51,14 +51,14 @@ impl<CTX: QueryContext, K, C: Default> Default for QueryStateShard<CTX, K, C> {
51
51
}
52
52
}
53
53
54
- pub ( crate ) struct QueryState < CTX : QueryContext , C : QueryCache > {
54
+ pub ( crate ) struct QueryState < CTX : QueryContext , C : QueryCache < CTX > > {
55
55
cache : C ,
56
56
shards : Sharded < QueryStateShard < CTX , C :: Key , C :: Sharded > > ,
57
57
#[ cfg( debug_assertions) ]
58
58
pub ( super ) cache_hits : AtomicUsize ,
59
59
}
60
60
61
- impl < CTX : QueryContext , C : QueryCache > QueryState < CTX , C > {
61
+ impl < CTX : QueryContext , C : QueryCache < CTX > > QueryState < CTX , C > {
62
62
pub ( super ) fn get_lookup < K2 : Hash > (
63
63
& ' tcx self ,
64
64
key : & K2 ,
@@ -86,7 +86,7 @@ enum QueryResult<CTX: QueryContext> {
86
86
Poisoned ,
87
87
}
88
88
89
- impl < CTX : QueryContext , C : QueryCache > QueryState < CTX , C > {
89
+ impl < CTX : QueryContext , C : QueryCache < CTX > > QueryState < CTX , C > {
90
90
pub ( super ) fn iter_results < R > (
91
91
& self ,
92
92
f : impl for < ' a > FnOnce (
@@ -130,7 +130,7 @@ impl<CTX: QueryContext, C: QueryCache> QueryState<CTX, C> {
130
130
}
131
131
}
132
132
133
- impl < CTX : QueryContext , C : QueryCache > Default for QueryState < CTX , C > {
133
+ impl < CTX : QueryContext , C : QueryCache < CTX > > Default for QueryState < CTX , C > {
134
134
fn default ( ) -> QueryState < CTX , C > {
135
135
QueryState {
136
136
cache : C :: default ( ) ,
@@ -152,7 +152,7 @@ pub(crate) struct QueryLookup<'tcx, CTX: QueryContext, K, C> {
152
152
/// This will poison the relevant query if dropped.
153
153
struct JobOwner < ' tcx , CTX : QueryContext , C >
154
154
where
155
- C : QueryCache ,
155
+ C : QueryCache < CTX > ,
156
156
C :: Key : Eq + Hash + Clone + Debug ,
157
157
C :: Value : Clone ,
158
158
{
@@ -161,9 +161,9 @@ where
161
161
id : QueryJobId ,
162
162
}
163
163
164
- impl < ' tcx , C : QueryCache > JobOwner < ' tcx , TyCtxt < ' tcx > , C >
164
+ impl < ' tcx , C > JobOwner < ' tcx , TyCtxt < ' tcx > , C >
165
165
where
166
- C : QueryCache ,
166
+ C : QueryCache < TyCtxt < ' tcx > > + ' tcx ,
167
167
C :: Key : Eq + Hash + Clone + Debug ,
168
168
C :: Value : Clone ,
169
169
{
@@ -176,12 +176,12 @@ where
176
176
/// This function is inlined because that results in a noticeable speed-up
177
177
/// for some compile-time benchmarks.
178
178
#[ inline( always) ]
179
- fn try_start < Q > (
179
+ fn try_start < ' a , ' b , Q > (
180
180
tcx : TyCtxt < ' tcx > ,
181
181
span : Span ,
182
182
key : & C :: Key ,
183
- mut lookup : QueryLookup < ' tcx , TyCtxt < ' tcx > , C :: Key , C :: Sharded > ,
184
- ) -> TryGetJob < ' tcx , C >
183
+ mut lookup : QueryLookup < ' a , TyCtxt < ' tcx > , C :: Key , C :: Sharded > ,
184
+ ) -> TryGetJob < ' b , TyCtxt < ' tcx > , C >
185
185
where
186
186
Q : QueryDescription < TyCtxt < ' tcx > , Key = C :: Key , Value = C :: Value , Cache = C > ,
187
187
{
@@ -262,16 +262,16 @@ where
262
262
}
263
263
}
264
264
265
- impl < ' tcx , CTX : QueryContext , C : QueryCache > JobOwner < ' tcx , CTX , C >
265
+ impl < ' tcx , CTX : QueryContext , C > JobOwner < ' tcx , CTX , C >
266
266
where
267
- C : QueryCache ,
267
+ C : QueryCache < CTX > ,
268
268
C :: Key : Eq + Hash + Clone + Debug ,
269
269
C :: Value : Clone ,
270
270
{
271
271
/// Completes the query by updating the query cache with the `result`,
272
272
/// signals the waiter and forgets the JobOwner, so it won't poison the query
273
273
#[ inline( always) ]
274
- fn complete ( self , tcx : TyCtxt < ' tcx > , result : & C :: Value , dep_node_index : DepNodeIndex ) {
274
+ fn complete ( self , tcx : CTX , result : & C :: Value , dep_node_index : DepNodeIndex ) {
275
275
// We can move out of `self` here because we `mem::forget` it below
276
276
let key = unsafe { ptr:: read ( & self . key ) } ;
277
277
let state = self . state ;
@@ -304,7 +304,7 @@ where
304
304
( result, diagnostics. into_inner ( ) )
305
305
}
306
306
307
- impl < ' tcx , CTX : QueryContext , C : QueryCache > Drop for JobOwner < ' tcx , CTX , C >
307
+ impl < ' tcx , CTX : QueryContext , C : QueryCache < CTX > > Drop for JobOwner < ' tcx , CTX , C >
308
308
where
309
309
C :: Key : Eq + Hash + Clone + Debug ,
310
310
C :: Value : Clone ,
@@ -338,13 +338,13 @@ pub(crate) struct CycleError<CTX: QueryContext> {
338
338
}
339
339
340
340
/// The result of `try_start`.
341
- enum TryGetJob < ' tcx , C : QueryCache >
341
+ enum TryGetJob < ' tcx , CTX : QueryContext , C : QueryCache < CTX > >
342
342
where
343
343
C :: Key : Eq + Hash + Clone + Debug ,
344
344
C :: Value : Clone ,
345
345
{
346
346
/// The query is not yet started. Contains a guard to the cache eventually used to start it.
347
- NotYetStarted ( JobOwner < ' tcx , TyCtxt < ' tcx > , C > ) ,
347
+ NotYetStarted ( JobOwner < ' tcx , CTX , C > ) ,
348
348
349
349
/// The query was already completed.
350
350
/// Returns the result of the query and its dep-node index
@@ -504,9 +504,9 @@ impl<'tcx> TyCtxt<'tcx> {
504
504
on_miss : OnMiss ,
505
505
) -> R
506
506
where
507
- C : QueryCache ,
507
+ C : QueryCache < TyCtxt < ' tcx > > ,
508
508
OnHit : FnOnce ( & C :: Value , DepNodeIndex ) -> R ,
509
- OnMiss : FnOnce ( C :: Key , QueryLookup < ' tcx , TyCtxt < ' tcx > , C :: Key , C :: Sharded > ) -> R ,
509
+ OnMiss : FnOnce ( C :: Key , QueryLookup < ' _ , TyCtxt < ' tcx > , C :: Key , C :: Sharded > ) -> R ,
510
510
{
511
511
state. cache . lookup (
512
512
state,
@@ -550,7 +550,12 @@ impl<'tcx> TyCtxt<'tcx> {
550
550
self ,
551
551
span : Span ,
552
552
key : Q :: Key ,
553
- lookup : QueryLookup < ' tcx , TyCtxt < ' tcx > , Q :: Key , <Q :: Cache as QueryCache >:: Sharded > ,
553
+ lookup : QueryLookup <
554
+ ' _ ,
555
+ TyCtxt < ' tcx > ,
556
+ Q :: Key ,
557
+ <Q :: Cache as QueryCache < TyCtxt < ' tcx > > >:: Sharded ,
558
+ > ,
554
559
) -> Q :: Value {
555
560
let job = match JobOwner :: try_start :: < Q > ( self , span, & key, lookup) {
556
561
TryGetJob :: NotYetStarted ( job) => job,
@@ -866,14 +871,14 @@ macro_rules! is_eval_always {
866
871
}
867
872
868
873
macro_rules! query_storage {
869
- ( [ ] [ $K: ty, $V: ty] ) => {
870
- <<$K as Key >:: CacheSelector as CacheSelector <$K, $V>>:: Cache
874
+ ( <$tcx : tt> [ ] [ $K: ty, $V: ty] ) => {
875
+ <<$K as Key >:: CacheSelector as CacheSelector <TyCtxt <$tcx> , $K, $V>>:: Cache
871
876
} ;
872
- ( [ storage( $ty: ty) $( $rest: tt) * ] [ $K: ty, $V: ty] ) => {
877
+ ( <$tcx : tt> [ storage( $ty: ty) $( $rest: tt) * ] [ $K: ty, $V: ty] ) => {
873
878
$ty
874
879
} ;
875
- ( [ $other: ident $( ( $( $other_args: tt) * ) ) * $( , $( $modifiers: tt) * ) * ] [ $( $args: tt) * ] ) => {
876
- query_storage!( [ $( $( $modifiers) * ) * ] [ $( $args) * ] )
880
+ ( <$tcx : tt> [ $other: ident $( ( $( $other_args: tt) * ) ) * $( , $( $modifiers: tt) * ) * ] [ $( $args: tt) * ] ) => {
881
+ query_storage!( <$tcx> [ $( $( $modifiers) * ) * ] [ $( $args) * ] )
877
882
} ;
878
883
}
879
884
@@ -989,7 +994,7 @@ macro_rules! define_queries_inner {
989
994
const EVAL_ALWAYS : bool = is_eval_always!( [ $( $modifiers) * ] ) ;
990
995
const DEP_KIND : dep_graph:: DepKind = dep_graph:: DepKind :: $node;
991
996
992
- type Cache = query_storage!( [ $( $modifiers) * ] [ $K, $V] ) ;
997
+ type Cache = query_storage!( <$tcx> [ $( $modifiers) * ] [ $K, $V] ) ;
993
998
994
999
#[ inline( always) ]
995
1000
fn query_state<' a>( tcx: TyCtxt <$tcx>) -> & ' a QueryState <TyCtxt <$tcx>, Self :: Cache > {
0 commit comments