@@ -14,16 +14,17 @@ use rustc_span::{Span, DUMMY_SP};
14
14
pub trait Key {
15
15
/// Given an instance of this key, what crate is it referring to?
16
16
/// This is used to find the provider.
17
- fn query_crate ( & self ) -> CrateNum ;
17
+ fn query_crate_is_local ( & self ) -> bool ;
18
18
19
19
/// In the event that a cycle occurs, if no explicit span has been
20
20
/// given for a query with key `self`, what span should we use?
21
21
fn default_span ( & self , tcx : TyCtxt < ' _ > ) -> Span ;
22
22
}
23
23
24
24
impl Key for ( ) {
25
- fn query_crate ( & self ) -> CrateNum {
26
- LOCAL_CRATE
25
+ #[ inline( always) ]
26
+ fn query_crate_is_local ( & self ) -> bool {
27
+ true
27
28
}
28
29
29
30
fn default_span ( & self , _: TyCtxt < ' _ > ) -> Span {
@@ -32,8 +33,9 @@ impl Key for () {
32
33
}
33
34
34
35
impl < ' tcx > Key for ty:: InstanceDef < ' tcx > {
35
- fn query_crate ( & self ) -> CrateNum {
36
- LOCAL_CRATE
36
+ #[ inline( always) ]
37
+ fn query_crate_is_local ( & self ) -> bool {
38
+ true
37
39
}
38
40
39
41
fn default_span ( & self , tcx : TyCtxt < ' _ > ) -> Span {
@@ -42,8 +44,9 @@ impl<'tcx> Key for ty::InstanceDef<'tcx> {
42
44
}
43
45
44
46
impl < ' tcx > Key for ty:: Instance < ' tcx > {
45
- fn query_crate ( & self ) -> CrateNum {
46
- LOCAL_CRATE
47
+ #[ inline( always) ]
48
+ fn query_crate_is_local ( & self ) -> bool {
49
+ true
47
50
}
48
51
49
52
fn default_span ( & self , tcx : TyCtxt < ' _ > ) -> Span {
@@ -52,8 +55,9 @@ impl<'tcx> Key for ty::Instance<'tcx> {
52
55
}
53
56
54
57
impl < ' tcx > Key for mir:: interpret:: GlobalId < ' tcx > {
55
- fn query_crate ( & self ) -> CrateNum {
56
- self . instance . query_crate ( )
58
+ #[ inline( always) ]
59
+ fn query_crate_is_local ( & self ) -> bool {
60
+ true
57
61
}
58
62
59
63
fn default_span ( & self , tcx : TyCtxt < ' _ > ) -> Span {
@@ -62,8 +66,9 @@ impl<'tcx> Key for mir::interpret::GlobalId<'tcx> {
62
66
}
63
67
64
68
impl < ' tcx > Key for mir:: interpret:: LitToConstInput < ' tcx > {
65
- fn query_crate ( & self ) -> CrateNum {
66
- LOCAL_CRATE
69
+ #[ inline( always) ]
70
+ fn query_crate_is_local ( & self ) -> bool {
71
+ true
67
72
}
68
73
69
74
fn default_span ( & self , _tcx : TyCtxt < ' _ > ) -> Span {
@@ -72,125 +77,139 @@ impl<'tcx> Key for mir::interpret::LitToConstInput<'tcx> {
72
77
}
73
78
74
79
impl Key for CrateNum {
75
- fn query_crate ( & self ) -> CrateNum {
76
- * self
80
+ #[ inline( always) ]
81
+ fn query_crate_is_local ( & self ) -> bool {
82
+ * self == LOCAL_CRATE
77
83
}
78
84
fn default_span ( & self , _: TyCtxt < ' _ > ) -> Span {
79
85
DUMMY_SP
80
86
}
81
87
}
82
88
83
89
impl Key for LocalDefId {
84
- fn query_crate ( & self ) -> CrateNum {
85
- self . to_def_id ( ) . query_crate ( )
90
+ #[ inline( always) ]
91
+ fn query_crate_is_local ( & self ) -> bool {
92
+ true
86
93
}
87
94
fn default_span ( & self , tcx : TyCtxt < ' _ > ) -> Span {
88
95
self . to_def_id ( ) . default_span ( tcx)
89
96
}
90
97
}
91
98
92
99
impl Key for DefId {
93
- fn query_crate ( & self ) -> CrateNum {
94
- self . krate
100
+ #[ inline( always) ]
101
+ fn query_crate_is_local ( & self ) -> bool {
102
+ self . krate == LOCAL_CRATE
95
103
}
96
104
fn default_span ( & self , tcx : TyCtxt < ' _ > ) -> Span {
97
105
tcx. def_span ( * self )
98
106
}
99
107
}
100
108
101
109
impl Key for ty:: WithOptConstParam < LocalDefId > {
102
- fn query_crate ( & self ) -> CrateNum {
103
- self . did . query_crate ( )
110
+ #[ inline( always) ]
111
+ fn query_crate_is_local ( & self ) -> bool {
112
+ true
104
113
}
105
114
fn default_span ( & self , tcx : TyCtxt < ' _ > ) -> Span {
106
115
self . did . default_span ( tcx)
107
116
}
108
117
}
109
118
110
119
impl Key for ( DefId , DefId ) {
111
- fn query_crate ( & self ) -> CrateNum {
112
- self . 0 . krate
120
+ #[ inline( always) ]
121
+ fn query_crate_is_local ( & self ) -> bool {
122
+ self . 0 . krate == LOCAL_CRATE
113
123
}
114
124
fn default_span ( & self , tcx : TyCtxt < ' _ > ) -> Span {
115
125
self . 1 . default_span ( tcx)
116
126
}
117
127
}
118
128
119
129
impl Key for ( ty:: Instance < ' tcx > , LocalDefId ) {
120
- fn query_crate ( & self ) -> CrateNum {
121
- self . 0 . query_crate ( )
130
+ #[ inline( always) ]
131
+ fn query_crate_is_local ( & self ) -> bool {
132
+ true
122
133
}
123
134
fn default_span ( & self , tcx : TyCtxt < ' _ > ) -> Span {
124
135
self . 0 . default_span ( tcx)
125
136
}
126
137
}
127
138
128
139
impl Key for ( DefId , LocalDefId ) {
129
- fn query_crate ( & self ) -> CrateNum {
130
- self . 0 . krate
140
+ #[ inline( always) ]
141
+ fn query_crate_is_local ( & self ) -> bool {
142
+ self . 0 . krate == LOCAL_CRATE
131
143
}
132
144
fn default_span ( & self , tcx : TyCtxt < ' _ > ) -> Span {
133
145
self . 1 . default_span ( tcx)
134
146
}
135
147
}
136
148
137
149
impl Key for ( LocalDefId , DefId ) {
138
- fn query_crate ( & self ) -> CrateNum {
139
- LOCAL_CRATE
150
+ #[ inline( always) ]
151
+ fn query_crate_is_local ( & self ) -> bool {
152
+ true
140
153
}
141
154
fn default_span ( & self , tcx : TyCtxt < ' _ > ) -> Span {
142
155
self . 0 . default_span ( tcx)
143
156
}
144
157
}
145
158
146
159
impl Key for ( DefId , Option < Ident > ) {
147
- fn query_crate ( & self ) -> CrateNum {
148
- self . 0 . krate
160
+ #[ inline( always) ]
161
+ fn query_crate_is_local ( & self ) -> bool {
162
+ self . 0 . krate == LOCAL_CRATE
149
163
}
150
164
fn default_span ( & self , tcx : TyCtxt < ' _ > ) -> Span {
151
165
tcx. def_span ( self . 0 )
152
166
}
153
167
}
154
168
155
169
impl Key for ( DefId , LocalDefId , Ident ) {
156
- fn query_crate ( & self ) -> CrateNum {
157
- self . 0 . krate
170
+ #[ inline( always) ]
171
+ fn query_crate_is_local ( & self ) -> bool {
172
+ self . 0 . krate == LOCAL_CRATE
158
173
}
159
174
fn default_span ( & self , tcx : TyCtxt < ' _ > ) -> Span {
160
175
self . 1 . default_span ( tcx)
161
176
}
162
177
}
163
178
164
179
impl Key for ( CrateNum , DefId ) {
165
- fn query_crate ( & self ) -> CrateNum {
166
- self . 0
180
+ #[ inline( always) ]
181
+ fn query_crate_is_local ( & self ) -> bool {
182
+ self . 0 == LOCAL_CRATE
167
183
}
168
184
fn default_span ( & self , tcx : TyCtxt < ' _ > ) -> Span {
169
185
self . 1 . default_span ( tcx)
170
186
}
171
187
}
172
188
173
189
impl Key for ( DefId , SimplifiedType ) {
174
- fn query_crate ( & self ) -> CrateNum {
175
- self . 0 . krate
190
+ #[ inline( always) ]
191
+ fn query_crate_is_local ( & self ) -> bool {
192
+ self . 0 . krate == LOCAL_CRATE
176
193
}
177
194
fn default_span ( & self , tcx : TyCtxt < ' _ > ) -> Span {
178
195
self . 0 . default_span ( tcx)
179
196
}
180
197
}
181
198
182
199
impl < ' tcx > Key for SubstsRef < ' tcx > {
183
- fn query_crate ( & self ) -> CrateNum {
184
- LOCAL_CRATE
200
+ #[ inline( always) ]
201
+ fn query_crate_is_local ( & self ) -> bool {
202
+ true
185
203
}
186
204
fn default_span ( & self , _: TyCtxt < ' _ > ) -> Span {
187
205
DUMMY_SP
188
206
}
189
207
}
190
208
191
209
impl < ' tcx > Key for ( DefId , SubstsRef < ' tcx > ) {
192
- fn query_crate ( & self ) -> CrateNum {
193
- self . 0 . krate
210
+ #[ inline( always) ]
211
+ fn query_crate_is_local ( & self ) -> bool {
212
+ self . 0 . krate == LOCAL_CRATE
194
213
}
195
214
fn default_span ( & self , tcx : TyCtxt < ' _ > ) -> Span {
196
215
self . 0 . default_span ( tcx)
@@ -203,125 +222,139 @@ impl<'tcx> Key
203
222
( ty:: WithOptConstParam < DefId > , SubstsRef < ' tcx > ) ,
204
223
)
205
224
{
206
- fn query_crate ( & self ) -> CrateNum {
207
- ( self . 0 ) . 0 . did . krate
225
+ #[ inline( always) ]
226
+ fn query_crate_is_local ( & self ) -> bool {
227
+ ( self . 0 ) . 0 . did . krate == LOCAL_CRATE
208
228
}
209
229
fn default_span ( & self , tcx : TyCtxt < ' _ > ) -> Span {
210
230
( self . 0 ) . 0 . did . default_span ( tcx)
211
231
}
212
232
}
213
233
214
234
impl < ' tcx > Key for ( LocalDefId , DefId , SubstsRef < ' tcx > ) {
215
- fn query_crate ( & self ) -> CrateNum {
216
- LOCAL_CRATE
235
+ #[ inline( always) ]
236
+ fn query_crate_is_local ( & self ) -> bool {
237
+ true
217
238
}
218
239
fn default_span ( & self , tcx : TyCtxt < ' _ > ) -> Span {
219
240
self . 0 . default_span ( tcx)
220
241
}
221
242
}
222
243
223
244
impl < ' tcx > Key for ( ty:: ParamEnv < ' tcx > , ty:: PolyTraitRef < ' tcx > ) {
224
- fn query_crate ( & self ) -> CrateNum {
225
- self . 1 . def_id ( ) . krate
245
+ #[ inline( always) ]
246
+ fn query_crate_is_local ( & self ) -> bool {
247
+ self . 1 . def_id ( ) . krate == LOCAL_CRATE
226
248
}
227
249
fn default_span ( & self , tcx : TyCtxt < ' _ > ) -> Span {
228
250
tcx. def_span ( self . 1 . def_id ( ) )
229
251
}
230
252
}
231
253
232
254
impl < ' tcx > Key for ( & ' tcx ty:: Const < ' tcx > , mir:: Field ) {
233
- fn query_crate ( & self ) -> CrateNum {
234
- LOCAL_CRATE
255
+ #[ inline( always) ]
256
+ fn query_crate_is_local ( & self ) -> bool {
257
+ true
235
258
}
236
259
fn default_span ( & self , _: TyCtxt < ' _ > ) -> Span {
237
260
DUMMY_SP
238
261
}
239
262
}
240
263
241
264
impl < ' tcx > Key for mir:: interpret:: ConstAlloc < ' tcx > {
242
- fn query_crate ( & self ) -> CrateNum {
243
- LOCAL_CRATE
265
+ #[ inline( always) ]
266
+ fn query_crate_is_local ( & self ) -> bool {
267
+ true
244
268
}
245
269
fn default_span ( & self , _: TyCtxt < ' _ > ) -> Span {
246
270
DUMMY_SP
247
271
}
248
272
}
249
273
250
274
impl < ' tcx > Key for ty:: PolyTraitRef < ' tcx > {
251
- fn query_crate ( & self ) -> CrateNum {
252
- self . def_id ( ) . krate
275
+ #[ inline( always) ]
276
+ fn query_crate_is_local ( & self ) -> bool {
277
+ self . def_id ( ) . krate == LOCAL_CRATE
253
278
}
254
279
fn default_span ( & self , tcx : TyCtxt < ' _ > ) -> Span {
255
280
tcx. def_span ( self . def_id ( ) )
256
281
}
257
282
}
258
283
259
284
impl < ' tcx > Key for GenericArg < ' tcx > {
260
- fn query_crate ( & self ) -> CrateNum {
261
- LOCAL_CRATE
285
+ #[ inline( always) ]
286
+ fn query_crate_is_local ( & self ) -> bool {
287
+ true
262
288
}
263
289
fn default_span ( & self , _: TyCtxt < ' _ > ) -> Span {
264
290
DUMMY_SP
265
291
}
266
292
}
267
293
268
294
impl < ' tcx > Key for mir:: ConstantKind < ' tcx > {
269
- fn query_crate ( & self ) -> CrateNum {
270
- LOCAL_CRATE
295
+ #[ inline( always) ]
296
+ fn query_crate_is_local ( & self ) -> bool {
297
+ true
271
298
}
272
299
fn default_span ( & self , _: TyCtxt < ' _ > ) -> Span {
273
300
DUMMY_SP
274
301
}
275
302
}
276
303
277
304
impl < ' tcx > Key for & ' tcx ty:: Const < ' tcx > {
278
- fn query_crate ( & self ) -> CrateNum {
279
- LOCAL_CRATE
305
+ #[ inline( always) ]
306
+ fn query_crate_is_local ( & self ) -> bool {
307
+ true
280
308
}
281
309
fn default_span ( & self , _: TyCtxt < ' _ > ) -> Span {
282
310
DUMMY_SP
283
311
}
284
312
}
285
313
286
314
impl < ' tcx > Key for Ty < ' tcx > {
287
- fn query_crate ( & self ) -> CrateNum {
288
- LOCAL_CRATE
315
+ #[ inline( always) ]
316
+ fn query_crate_is_local ( & self ) -> bool {
317
+ true
289
318
}
290
319
fn default_span ( & self , _: TyCtxt < ' _ > ) -> Span {
291
320
DUMMY_SP
292
321
}
293
322
}
294
323
295
324
impl < ' tcx > Key for & ' tcx ty:: List < ty:: Predicate < ' tcx > > {
296
- fn query_crate ( & self ) -> CrateNum {
297
- LOCAL_CRATE
325
+ #[ inline( always) ]
326
+ fn query_crate_is_local ( & self ) -> bool {
327
+ true
298
328
}
299
329
fn default_span ( & self , _: TyCtxt < ' _ > ) -> Span {
300
330
DUMMY_SP
301
331
}
302
332
}
303
333
304
334
impl < ' tcx > Key for ty:: ParamEnv < ' tcx > {
305
- fn query_crate ( & self ) -> CrateNum {
306
- LOCAL_CRATE
335
+ #[ inline( always) ]
336
+ fn query_crate_is_local ( & self ) -> bool {
337
+ true
307
338
}
308
339
fn default_span ( & self , _: TyCtxt < ' _ > ) -> Span {
309
340
DUMMY_SP
310
341
}
311
342
}
312
343
313
344
impl < ' tcx , T : Key > Key for ty:: ParamEnvAnd < ' tcx , T > {
314
- fn query_crate ( & self ) -> CrateNum {
315
- self . value . query_crate ( )
345
+ #[ inline( always) ]
346
+ fn query_crate_is_local ( & self ) -> bool {
347
+ self . value . query_crate_is_local ( )
316
348
}
317
349
fn default_span ( & self , tcx : TyCtxt < ' _ > ) -> Span {
318
350
self . value . default_span ( tcx)
319
351
}
320
352
}
321
353
322
354
impl Key for Symbol {
323
- fn query_crate ( & self ) -> CrateNum {
324
- LOCAL_CRATE
355
+ #[ inline( always) ]
356
+ fn query_crate_is_local ( & self ) -> bool {
357
+ true
325
358
}
326
359
fn default_span ( & self , _tcx : TyCtxt < ' _ > ) -> Span {
327
360
DUMMY_SP
@@ -331,8 +364,9 @@ impl Key for Symbol {
331
364
/// Canonical query goals correspond to abstract trait operations that
332
365
/// are not tied to any crate in particular.
333
366
impl < ' tcx , T > Key for Canonical < ' tcx , T > {
334
- fn query_crate ( & self ) -> CrateNum {
335
- LOCAL_CRATE
367
+ #[ inline( always) ]
368
+ fn query_crate_is_local ( & self ) -> bool {
369
+ true
336
370
}
337
371
338
372
fn default_span ( & self , _tcx : TyCtxt < ' _ > ) -> Span {
@@ -341,8 +375,9 @@ impl<'tcx, T> Key for Canonical<'tcx, T> {
341
375
}
342
376
343
377
impl Key for ( Symbol , u32 , u32 ) {
344
- fn query_crate ( & self ) -> CrateNum {
345
- LOCAL_CRATE
378
+ #[ inline( always) ]
379
+ fn query_crate_is_local ( & self ) -> bool {
380
+ true
346
381
}
347
382
348
383
fn default_span ( & self , _tcx : TyCtxt < ' _ > ) -> Span {
@@ -351,8 +386,9 @@ impl Key for (Symbol, u32, u32) {
351
386
}
352
387
353
388
impl < ' tcx > Key for ( DefId , Ty < ' tcx > , SubstsRef < ' tcx > , ty:: ParamEnv < ' tcx > ) {
354
- fn query_crate ( & self ) -> CrateNum {
355
- LOCAL_CRATE
389
+ #[ inline( always) ]
390
+ fn query_crate_is_local ( & self ) -> bool {
391
+ true
356
392
}
357
393
358
394
fn default_span ( & self , _tcx : TyCtxt < ' _ > ) -> Span {
0 commit comments