4
4
5
5
use crate :: dep_graph:: { DepNode , DepNodeIndex , SerializedDepNodeIndex } ;
6
6
use crate :: ty:: query:: caches:: QueryCache ;
7
- use crate :: ty:: query:: config:: { QueryAccessors , QueryDescription } ;
7
+ use crate :: ty:: query:: config:: { QueryAccessors , QueryConfig , QueryDescription } ;
8
8
use crate :: ty:: query:: job:: { QueryInfo , QueryJob , QueryJobId , QueryShardJobId } ;
9
9
use crate :: ty:: query:: Query ;
10
10
use crate :: ty:: tls;
@@ -27,25 +27,32 @@ use std::ptr;
27
27
#[ cfg( debug_assertions) ]
28
28
use std:: sync:: atomic:: { AtomicUsize , Ordering } ;
29
29
30
- pub ( crate ) struct QueryStateShard < ' tcx , D : QueryAccessors < ' tcx > + ?Sized > {
31
- pub ( super ) cache : <<D as QueryAccessors < ' tcx > >:: Cache as QueryCache < D :: Key , D :: Value > >:: Sharded ,
32
- pub ( super ) active : FxHashMap < D :: Key , QueryResult < ' tcx > > ,
30
+ pub ( crate ) type QueryStateShard < ' tcx , Q > = QueryStateShardImpl <
31
+ ' tcx ,
32
+ <Q as QueryConfig < ' tcx > >:: Key ,
33
+ <<Q as QueryAccessors < ' tcx > >:: Cache as QueryCache <
34
+ <Q as QueryConfig < ' tcx > >:: Key ,
35
+ <Q as QueryConfig < ' tcx > >:: Value ,
36
+ > >:: Sharded ,
37
+ > ;
38
+
39
+ pub ( crate ) struct QueryStateShardImpl < ' tcx , K , C > {
40
+ pub ( super ) cache : C ,
41
+ pub ( super ) active : FxHashMap < K , QueryResult < ' tcx > > ,
33
42
34
43
/// Used to generate unique ids for active jobs.
35
44
pub ( super ) jobs : u32 ,
36
45
}
37
46
38
- impl < ' tcx , Q : QueryAccessors < ' tcx > > QueryStateShard < ' tcx , Q > {
39
- fn get_cache (
40
- & mut self ,
41
- ) -> & mut <<Q as QueryAccessors < ' tcx > >:: Cache as QueryCache < Q :: Key , Q :: Value > >:: Sharded {
47
+ impl < ' tcx , K , C > QueryStateShardImpl < ' tcx , K , C > {
48
+ fn get_cache ( & mut self ) -> & mut C {
42
49
& mut self . cache
43
50
}
44
51
}
45
52
46
- impl < ' tcx , Q : QueryAccessors < ' tcx > > Default for QueryStateShard < ' tcx , Q > {
47
- fn default ( ) -> QueryStateShard < ' tcx , Q > {
48
- QueryStateShard { cache : Default :: default ( ) , active : Default :: default ( ) , jobs : 0 }
53
+ impl < ' tcx , K , C : Default > Default for QueryStateShardImpl < ' tcx , K , C > {
54
+ fn default ( ) -> QueryStateShardImpl < ' tcx , K , C > {
55
+ QueryStateShardImpl { cache : Default :: default ( ) , active : Default :: default ( ) , jobs : 0 }
49
56
}
50
57
}
51
58
@@ -122,7 +129,7 @@ pub(super) struct JobOwner<'tcx, Q: QueryDescription<'tcx>> {
122
129
id : QueryJobId ,
123
130
}
124
131
125
- impl < ' tcx , Q : QueryDescription < ' tcx > > JobOwner < ' tcx , Q > {
132
+ impl < ' tcx , Q : QueryDescription < ' tcx > + ' tcx > JobOwner < ' tcx , Q > {
126
133
/// Either gets a `JobOwner` corresponding the query, allowing us to
127
134
/// start executing the query, or returns with the result of the query.
128
135
/// This function assumes that `try_get_cached` is already called and returned `lookup`.
@@ -470,7 +477,7 @@ impl<'tcx> TyCtxt<'tcx> {
470
477
}
471
478
472
479
#[ inline( always) ]
473
- pub ( super ) fn try_execute_query < Q : QueryDescription < ' tcx > > (
480
+ pub ( super ) fn try_execute_query < Q : QueryDescription < ' tcx > + ' tcx > (
474
481
self ,
475
482
span : Span ,
476
483
key : Q :: Key ,
@@ -634,7 +641,7 @@ impl<'tcx> TyCtxt<'tcx> {
634
641
}
635
642
636
643
#[ inline( always) ]
637
- fn force_query_with_job < Q : QueryDescription < ' tcx > > (
644
+ fn force_query_with_job < Q : QueryDescription < ' tcx > + ' tcx > (
638
645
self ,
639
646
key : Q :: Key ,
640
647
job : JobOwner < ' tcx , Q > ,
0 commit comments