@@ -4,6 +4,7 @@ use crate::infer::canonical::Canonical;
4
4
use crate :: mir;
5
5
use crate :: traits;
6
6
use crate :: ty:: fast_reject:: SimplifiedType ;
7
+ use crate :: ty:: query:: caches:: DefaultCacheSelector ;
7
8
use crate :: ty:: subst:: SubstsRef ;
8
9
use crate :: ty:: { self , Ty , TyCtxt } ;
9
10
use rustc_hir:: def_id:: { CrateNum , DefId , DefIndex , LOCAL_CRATE } ;
@@ -12,7 +13,9 @@ use rustc_span::{Span, DUMMY_SP};
12
13
13
14
/// The `Key` trait controls what types can legally be used as the key
14
15
/// for a query.
15
- pub ( super ) trait Key {
16
+ pub trait Key {
17
+ type CacheSelector ;
18
+
16
19
/// Given an instance of this key, what crate is it referring to?
17
20
/// This is used to find the provider.
18
21
fn query_crate ( & self ) -> CrateNum ;
@@ -23,6 +26,8 @@ pub(super) trait Key {
23
26
}
24
27
25
28
impl < ' tcx > Key for ty:: InstanceDef < ' tcx > {
29
+ type CacheSelector = DefaultCacheSelector ;
30
+
26
31
fn query_crate ( & self ) -> CrateNum {
27
32
LOCAL_CRATE
28
33
}
@@ -33,6 +38,8 @@ impl<'tcx> Key for ty::InstanceDef<'tcx> {
33
38
}
34
39
35
40
impl < ' tcx > Key for ty:: Instance < ' tcx > {
41
+ type CacheSelector = DefaultCacheSelector ;
42
+
36
43
fn query_crate ( & self ) -> CrateNum {
37
44
LOCAL_CRATE
38
45
}
@@ -43,6 +50,8 @@ impl<'tcx> Key for ty::Instance<'tcx> {
43
50
}
44
51
45
52
impl < ' tcx > Key for mir:: interpret:: GlobalId < ' tcx > {
53
+ type CacheSelector = DefaultCacheSelector ;
54
+
46
55
fn query_crate ( & self ) -> CrateNum {
47
56
self . instance . query_crate ( )
48
57
}
@@ -53,6 +62,8 @@ impl<'tcx> Key for mir::interpret::GlobalId<'tcx> {
53
62
}
54
63
55
64
impl < ' tcx > Key for mir:: interpret:: LitToConstInput < ' tcx > {
65
+ type CacheSelector = DefaultCacheSelector ;
66
+
56
67
fn query_crate ( & self ) -> CrateNum {
57
68
LOCAL_CRATE
58
69
}
@@ -63,6 +74,8 @@ impl<'tcx> Key for mir::interpret::LitToConstInput<'tcx> {
63
74
}
64
75
65
76
impl Key for CrateNum {
77
+ type CacheSelector = DefaultCacheSelector ;
78
+
66
79
fn query_crate ( & self ) -> CrateNum {
67
80
* self
68
81
}
@@ -72,6 +85,8 @@ impl Key for CrateNum {
72
85
}
73
86
74
87
impl Key for DefIndex {
88
+ type CacheSelector = DefaultCacheSelector ;
89
+
75
90
fn query_crate ( & self ) -> CrateNum {
76
91
LOCAL_CRATE
77
92
}
@@ -81,6 +96,8 @@ impl Key for DefIndex {
81
96
}
82
97
83
98
impl Key for DefId {
99
+ type CacheSelector = DefaultCacheSelector ;
100
+
84
101
fn query_crate ( & self ) -> CrateNum {
85
102
self . krate
86
103
}
@@ -90,6 +107,8 @@ impl Key for DefId {
90
107
}
91
108
92
109
impl Key for ( DefId , DefId ) {
110
+ type CacheSelector = DefaultCacheSelector ;
111
+
93
112
fn query_crate ( & self ) -> CrateNum {
94
113
self . 0 . krate
95
114
}
@@ -99,6 +118,8 @@ impl Key for (DefId, DefId) {
99
118
}
100
119
101
120
impl Key for ( CrateNum , DefId ) {
121
+ type CacheSelector = DefaultCacheSelector ;
122
+
102
123
fn query_crate ( & self ) -> CrateNum {
103
124
self . 0
104
125
}
@@ -108,6 +129,8 @@ impl Key for (CrateNum, DefId) {
108
129
}
109
130
110
131
impl Key for ( DefId , SimplifiedType ) {
132
+ type CacheSelector = DefaultCacheSelector ;
133
+
111
134
fn query_crate ( & self ) -> CrateNum {
112
135
self . 0 . krate
113
136
}
@@ -117,6 +140,8 @@ impl Key for (DefId, SimplifiedType) {
117
140
}
118
141
119
142
impl < ' tcx > Key for SubstsRef < ' tcx > {
143
+ type CacheSelector = DefaultCacheSelector ;
144
+
120
145
fn query_crate ( & self ) -> CrateNum {
121
146
LOCAL_CRATE
122
147
}
@@ -126,6 +151,8 @@ impl<'tcx> Key for SubstsRef<'tcx> {
126
151
}
127
152
128
153
impl < ' tcx > Key for ( DefId , SubstsRef < ' tcx > ) {
154
+ type CacheSelector = DefaultCacheSelector ;
155
+
129
156
fn query_crate ( & self ) -> CrateNum {
130
157
self . 0 . krate
131
158
}
@@ -135,6 +162,8 @@ impl<'tcx> Key for (DefId, SubstsRef<'tcx>) {
135
162
}
136
163
137
164
impl < ' tcx > Key for ( ty:: ParamEnv < ' tcx > , ty:: PolyTraitRef < ' tcx > ) {
165
+ type CacheSelector = DefaultCacheSelector ;
166
+
138
167
fn query_crate ( & self ) -> CrateNum {
139
168
self . 1 . def_id ( ) . krate
140
169
}
@@ -144,6 +173,8 @@ impl<'tcx> Key for (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>) {
144
173
}
145
174
146
175
impl < ' tcx > Key for ( & ' tcx ty:: Const < ' tcx > , mir:: Field ) {
176
+ type CacheSelector = DefaultCacheSelector ;
177
+
147
178
fn query_crate ( & self ) -> CrateNum {
148
179
LOCAL_CRATE
149
180
}
@@ -153,6 +184,8 @@ impl<'tcx> Key for (&'tcx ty::Const<'tcx>, mir::Field) {
153
184
}
154
185
155
186
impl < ' tcx > Key for ty:: PolyTraitRef < ' tcx > {
187
+ type CacheSelector = DefaultCacheSelector ;
188
+
156
189
fn query_crate ( & self ) -> CrateNum {
157
190
self . def_id ( ) . krate
158
191
}
@@ -162,6 +195,8 @@ impl<'tcx> Key for ty::PolyTraitRef<'tcx> {
162
195
}
163
196
164
197
impl < ' tcx > Key for & ' tcx ty:: Const < ' tcx > {
198
+ type CacheSelector = DefaultCacheSelector ;
199
+
165
200
fn query_crate ( & self ) -> CrateNum {
166
201
LOCAL_CRATE
167
202
}
@@ -171,6 +206,8 @@ impl<'tcx> Key for &'tcx ty::Const<'tcx> {
171
206
}
172
207
173
208
impl < ' tcx > Key for Ty < ' tcx > {
209
+ type CacheSelector = DefaultCacheSelector ;
210
+
174
211
fn query_crate ( & self ) -> CrateNum {
175
212
LOCAL_CRATE
176
213
}
@@ -180,6 +217,8 @@ impl<'tcx> Key for Ty<'tcx> {
180
217
}
181
218
182
219
impl < ' tcx > Key for ty:: ParamEnv < ' tcx > {
220
+ type CacheSelector = DefaultCacheSelector ;
221
+
183
222
fn query_crate ( & self ) -> CrateNum {
184
223
LOCAL_CRATE
185
224
}
@@ -189,6 +228,8 @@ impl<'tcx> Key for ty::ParamEnv<'tcx> {
189
228
}
190
229
191
230
impl < ' tcx , T : Key > Key for ty:: ParamEnvAnd < ' tcx , T > {
231
+ type CacheSelector = DefaultCacheSelector ;
232
+
192
233
fn query_crate ( & self ) -> CrateNum {
193
234
self . value . query_crate ( )
194
235
}
@@ -198,6 +239,8 @@ impl<'tcx, T: Key> Key for ty::ParamEnvAnd<'tcx, T> {
198
239
}
199
240
200
241
impl < ' tcx > Key for traits:: Environment < ' tcx > {
242
+ type CacheSelector = DefaultCacheSelector ;
243
+
201
244
fn query_crate ( & self ) -> CrateNum {
202
245
LOCAL_CRATE
203
246
}
@@ -207,6 +250,8 @@ impl<'tcx> Key for traits::Environment<'tcx> {
207
250
}
208
251
209
252
impl Key for Symbol {
253
+ type CacheSelector = DefaultCacheSelector ;
254
+
210
255
fn query_crate ( & self ) -> CrateNum {
211
256
LOCAL_CRATE
212
257
}
@@ -218,6 +263,8 @@ impl Key for Symbol {
218
263
/// Canonical query goals correspond to abstract trait operations that
219
264
/// are not tied to any crate in particular.
220
265
impl < ' tcx , T > Key for Canonical < ' tcx , T > {
266
+ type CacheSelector = DefaultCacheSelector ;
267
+
221
268
fn query_crate ( & self ) -> CrateNum {
222
269
LOCAL_CRATE
223
270
}
@@ -228,6 +275,8 @@ impl<'tcx, T> Key for Canonical<'tcx, T> {
228
275
}
229
276
230
277
impl Key for ( Symbol , u32 , u32 ) {
278
+ type CacheSelector = DefaultCacheSelector ;
279
+
231
280
fn query_crate ( & self ) -> CrateNum {
232
281
LOCAL_CRATE
233
282
}
0 commit comments