@@ -56,15 +56,25 @@ impl<'tcx, K, C: Default> Default for QueryStateShardImpl<'tcx, K, C> {
56
56
}
57
57
}
58
58
59
- pub ( crate ) struct QueryState < ' tcx , D : QueryAccessors < ' tcx > + ?Sized > {
60
- pub ( super ) cache : D :: Cache ,
61
- pub ( super ) shards : Sharded < QueryStateShard < ' tcx , D > > ,
59
+ pub ( crate ) type QueryState < ' tcx , Q > = QueryStateImpl <
60
+ ' tcx ,
61
+ <Q as QueryConfig < ' tcx > >:: Key ,
62
+ <Q as QueryConfig < ' tcx > >:: Value ,
63
+ <Q as QueryAccessors < ' tcx > >:: Cache ,
64
+ > ;
65
+
66
+ pub ( crate ) struct QueryStateImpl < ' tcx , K , V , C : QueryCache < K , V > > {
67
+ pub ( super ) cache : C ,
68
+ pub ( super ) shards : Sharded < QueryStateShardImpl < ' tcx , K , C :: Sharded > > ,
62
69
#[ cfg( debug_assertions) ]
63
70
pub ( super ) cache_hits : AtomicUsize ,
64
71
}
65
72
66
- impl < ' tcx , Q : QueryAccessors < ' tcx > > QueryState < ' tcx , Q > {
67
- pub ( super ) fn get_lookup < K : Hash > ( & ' tcx self , key : & K ) -> QueryLookup < ' tcx , Q > {
73
+ impl < ' tcx , K , V , C : QueryCache < K , V > > QueryStateImpl < ' tcx , K , V , C > {
74
+ pub ( super ) fn get_lookup < K2 : Hash > (
75
+ & ' tcx self ,
76
+ key : & K2 ,
77
+ ) -> QueryLookupImpl < ' tcx , QueryStateShardImpl < ' tcx , K , C :: Sharded > > {
68
78
// We compute the key's hash once and then use it for both the
69
79
// shard lookup and the hashmap lookup. This relies on the fact
70
80
// that both of them use `FxHasher`.
@@ -88,12 +98,10 @@ pub(super) enum QueryResult<'tcx> {
88
98
Poisoned ,
89
99
}
90
100
91
- impl < ' tcx , M : QueryAccessors < ' tcx > > QueryState < ' tcx , M > {
101
+ impl < ' tcx , K , V , C : QueryCache < K , V > > QueryStateImpl < ' tcx , K , V , C > {
92
102
pub fn iter_results < R > (
93
103
& self ,
94
- f : impl for < ' a > FnOnce (
95
- Box < dyn Iterator < Item = ( & ' a M :: Key , & ' a M :: Value , DepNodeIndex ) > + ' a > ,
96
- ) -> R ,
104
+ f : impl for < ' a > FnOnce ( Box < dyn Iterator < Item = ( & ' a K , & ' a V , DepNodeIndex ) > + ' a > ) -> R ,
97
105
) -> R {
98
106
self . cache . iter ( & self . shards , |shard| & mut shard. cache , f)
99
107
}
@@ -103,10 +111,10 @@ impl<'tcx, M: QueryAccessors<'tcx>> QueryState<'tcx, M> {
103
111
}
104
112
}
105
113
106
- impl < ' tcx , M : QueryAccessors < ' tcx > > Default for QueryState < ' tcx , M > {
107
- fn default ( ) -> QueryState < ' tcx , M > {
108
- QueryState {
109
- cache : M :: Cache :: default ( ) ,
114
+ impl < ' tcx , K , V , C : QueryCache < K , V > > Default for QueryStateImpl < ' tcx , K , V , C > {
115
+ fn default ( ) -> QueryStateImpl < ' tcx , K , V , C > {
116
+ QueryStateImpl {
117
+ cache : C :: default ( ) ,
110
118
shards : Default :: default ( ) ,
111
119
#[ cfg( debug_assertions) ]
112
120
cache_hits : AtomicUsize :: new ( 0 ) ,
@@ -441,7 +449,7 @@ impl<'tcx> TyCtxt<'tcx> {
441
449
{
442
450
let state = Q :: query_state ( self ) ;
443
451
444
- state. cache . lookup (
452
+ state. cache . lookup :: < _ , _ , _ , _ , Q > (
445
453
state,
446
454
QueryStateShard :: < Q > :: get_cache,
447
455
key,
@@ -1035,7 +1043,7 @@ macro_rules! define_queries_inner {
1035
1043
let mut string_cache = QueryKeyStringCache :: new( ) ;
1036
1044
1037
1045
$( {
1038
- alloc_self_profile_query_strings_for_query_cache(
1046
+ alloc_self_profile_query_strings_for_query_cache:: <queries :: $name< ' _>> (
1039
1047
self ,
1040
1048
stringify!( $name) ,
1041
1049
& self . queries. $name,
0 commit comments