Skip to content

Commit 3bd14c7

Browse files
committed
Select caching strategy per query.
The per-Key choice was not used.
1 parent 6e4af4a commit 3bd14c7

File tree

2 files changed

+1
-70
lines changed

2 files changed

+1
-70
lines changed

compiler/rustc_middle/src/ty/query/keys.rs

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,12 @@ use crate::ty::fast_reject::SimplifiedType;
66
use crate::ty::subst::{GenericArg, SubstsRef};
77
use crate::ty::{self, Ty, TyCtxt};
88
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LOCAL_CRATE};
9-
use rustc_query_system::query::DefaultCacheSelector;
109
use rustc_span::symbol::{Ident, Symbol};
1110
use rustc_span::{Span, DUMMY_SP};
1211

1312
/// The `Key` trait controls what types can legally be used as the key
1413
/// for a query.
1514
pub trait Key {
16-
type CacheSelector;
17-
1815
/// Given an instance of this key, what crate is it referring to?
1916
/// This is used to find the provider.
2017
fn query_crate(&self) -> CrateNum;
@@ -25,8 +22,6 @@ pub trait Key {
2522
}
2623

2724
impl<'tcx> Key for ty::InstanceDef<'tcx> {
28-
type CacheSelector = DefaultCacheSelector;
29-
3025
fn query_crate(&self) -> CrateNum {
3126
LOCAL_CRATE
3227
}
@@ -37,8 +32,6 @@ impl<'tcx> Key for ty::InstanceDef<'tcx> {
3732
}
3833

3934
impl<'tcx> Key for ty::Instance<'tcx> {
40-
type CacheSelector = DefaultCacheSelector;
41-
4235
fn query_crate(&self) -> CrateNum {
4336
LOCAL_CRATE
4437
}
@@ -49,8 +42,6 @@ impl<'tcx> Key for ty::Instance<'tcx> {
4942
}
5043

5144
impl<'tcx> Key for mir::interpret::GlobalId<'tcx> {
52-
type CacheSelector = DefaultCacheSelector;
53-
5445
fn query_crate(&self) -> CrateNum {
5546
self.instance.query_crate()
5647
}
@@ -61,8 +52,6 @@ impl<'tcx> Key for mir::interpret::GlobalId<'tcx> {
6152
}
6253

6354
impl<'tcx> Key for mir::interpret::LitToConstInput<'tcx> {
64-
type CacheSelector = DefaultCacheSelector;
65-
6655
fn query_crate(&self) -> CrateNum {
6756
LOCAL_CRATE
6857
}
@@ -73,8 +62,6 @@ impl<'tcx> Key for mir::interpret::LitToConstInput<'tcx> {
7362
}
7463

7564
impl Key for CrateNum {
76-
type CacheSelector = DefaultCacheSelector;
77-
7865
fn query_crate(&self) -> CrateNum {
7966
*self
8067
}
@@ -84,8 +71,6 @@ impl Key for CrateNum {
8471
}
8572

8673
impl Key for LocalDefId {
87-
type CacheSelector = DefaultCacheSelector;
88-
8974
fn query_crate(&self) -> CrateNum {
9075
self.to_def_id().query_crate()
9176
}
@@ -95,8 +80,6 @@ impl Key for LocalDefId {
9580
}
9681

9782
impl Key for DefId {
98-
type CacheSelector = DefaultCacheSelector;
99-
10083
fn query_crate(&self) -> CrateNum {
10184
self.krate
10285
}
@@ -106,8 +89,6 @@ impl Key for DefId {
10689
}
10790

10891
impl Key for ty::WithOptConstParam<LocalDefId> {
109-
type CacheSelector = DefaultCacheSelector;
110-
11192
fn query_crate(&self) -> CrateNum {
11293
self.did.query_crate()
11394
}
@@ -117,8 +98,6 @@ impl Key for ty::WithOptConstParam<LocalDefId> {
11798
}
11899

119100
impl Key for (DefId, DefId) {
120-
type CacheSelector = DefaultCacheSelector;
121-
122101
fn query_crate(&self) -> CrateNum {
123102
self.0.krate
124103
}
@@ -128,8 +107,6 @@ impl Key for (DefId, DefId) {
128107
}
129108

130109
impl Key for (ty::Instance<'tcx>, LocalDefId) {
131-
type CacheSelector = DefaultCacheSelector;
132-
133110
fn query_crate(&self) -> CrateNum {
134111
self.0.query_crate()
135112
}
@@ -139,8 +116,6 @@ impl Key for (ty::Instance<'tcx>, LocalDefId) {
139116
}
140117

141118
impl Key for (DefId, LocalDefId) {
142-
type CacheSelector = DefaultCacheSelector;
143-
144119
fn query_crate(&self) -> CrateNum {
145120
self.0.krate
146121
}
@@ -150,8 +125,6 @@ impl Key for (DefId, LocalDefId) {
150125
}
151126

152127
impl Key for (LocalDefId, DefId) {
153-
type CacheSelector = DefaultCacheSelector;
154-
155128
fn query_crate(&self) -> CrateNum {
156129
LOCAL_CRATE
157130
}
@@ -161,8 +134,6 @@ impl Key for (LocalDefId, DefId) {
161134
}
162135

163136
impl Key for (DefId, Option<Ident>) {
164-
type CacheSelector = DefaultCacheSelector;
165-
166137
fn query_crate(&self) -> CrateNum {
167138
self.0.krate
168139
}
@@ -172,8 +143,6 @@ impl Key for (DefId, Option<Ident>) {
172143
}
173144

174145
impl Key for (DefId, LocalDefId, Ident) {
175-
type CacheSelector = DefaultCacheSelector;
176-
177146
fn query_crate(&self) -> CrateNum {
178147
self.0.krate
179148
}
@@ -183,8 +152,6 @@ impl Key for (DefId, LocalDefId, Ident) {
183152
}
184153

185154
impl Key for (CrateNum, DefId) {
186-
type CacheSelector = DefaultCacheSelector;
187-
188155
fn query_crate(&self) -> CrateNum {
189156
self.0
190157
}
@@ -194,8 +161,6 @@ impl Key for (CrateNum, DefId) {
194161
}
195162

196163
impl Key for (DefId, SimplifiedType) {
197-
type CacheSelector = DefaultCacheSelector;
198-
199164
fn query_crate(&self) -> CrateNum {
200165
self.0.krate
201166
}
@@ -205,8 +170,6 @@ impl Key for (DefId, SimplifiedType) {
205170
}
206171

207172
impl<'tcx> Key for SubstsRef<'tcx> {
208-
type CacheSelector = DefaultCacheSelector;
209-
210173
fn query_crate(&self) -> CrateNum {
211174
LOCAL_CRATE
212175
}
@@ -216,8 +179,6 @@ impl<'tcx> Key for SubstsRef<'tcx> {
216179
}
217180

218181
impl<'tcx> Key for (DefId, SubstsRef<'tcx>) {
219-
type CacheSelector = DefaultCacheSelector;
220-
221182
fn query_crate(&self) -> CrateNum {
222183
self.0.krate
223184
}
@@ -232,8 +193,6 @@ impl<'tcx> Key
232193
(ty::WithOptConstParam<DefId>, SubstsRef<'tcx>),
233194
)
234195
{
235-
type CacheSelector = DefaultCacheSelector;
236-
237196
fn query_crate(&self) -> CrateNum {
238197
(self.0).0.did.krate
239198
}
@@ -243,8 +202,6 @@ impl<'tcx> Key
243202
}
244203

245204
impl<'tcx> Key for (LocalDefId, DefId, SubstsRef<'tcx>) {
246-
type CacheSelector = DefaultCacheSelector;
247-
248205
fn query_crate(&self) -> CrateNum {
249206
LOCAL_CRATE
250207
}
@@ -254,8 +211,6 @@ impl<'tcx> Key for (LocalDefId, DefId, SubstsRef<'tcx>) {
254211
}
255212

256213
impl<'tcx> Key for (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>) {
257-
type CacheSelector = DefaultCacheSelector;
258-
259214
fn query_crate(&self) -> CrateNum {
260215
self.1.def_id().krate
261216
}
@@ -265,8 +220,6 @@ impl<'tcx> Key for (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>) {
265220
}
266221

267222
impl<'tcx> Key for (&'tcx ty::Const<'tcx>, mir::Field) {
268-
type CacheSelector = DefaultCacheSelector;
269-
270223
fn query_crate(&self) -> CrateNum {
271224
LOCAL_CRATE
272225
}
@@ -276,8 +229,6 @@ impl<'tcx> Key for (&'tcx ty::Const<'tcx>, mir::Field) {
276229
}
277230

278231
impl<'tcx> Key for ty::PolyTraitRef<'tcx> {
279-
type CacheSelector = DefaultCacheSelector;
280-
281232
fn query_crate(&self) -> CrateNum {
282233
self.def_id().krate
283234
}
@@ -287,8 +238,6 @@ impl<'tcx> Key for ty::PolyTraitRef<'tcx> {
287238
}
288239

289240
impl<'tcx> Key for GenericArg<'tcx> {
290-
type CacheSelector = DefaultCacheSelector;
291-
292241
fn query_crate(&self) -> CrateNum {
293242
LOCAL_CRATE
294243
}
@@ -298,8 +247,6 @@ impl<'tcx> Key for GenericArg<'tcx> {
298247
}
299248

300249
impl<'tcx> Key for &'tcx ty::Const<'tcx> {
301-
type CacheSelector = DefaultCacheSelector;
302-
303250
fn query_crate(&self) -> CrateNum {
304251
LOCAL_CRATE
305252
}
@@ -309,8 +256,6 @@ impl<'tcx> Key for &'tcx ty::Const<'tcx> {
309256
}
310257

311258
impl<'tcx> Key for Ty<'tcx> {
312-
type CacheSelector = DefaultCacheSelector;
313-
314259
fn query_crate(&self) -> CrateNum {
315260
LOCAL_CRATE
316261
}
@@ -320,8 +265,6 @@ impl<'tcx> Key for Ty<'tcx> {
320265
}
321266

322267
impl<'tcx> Key for &'tcx ty::List<ty::Predicate<'tcx>> {
323-
type CacheSelector = DefaultCacheSelector;
324-
325268
fn query_crate(&self) -> CrateNum {
326269
LOCAL_CRATE
327270
}
@@ -331,8 +274,6 @@ impl<'tcx> Key for &'tcx ty::List<ty::Predicate<'tcx>> {
331274
}
332275

333276
impl<'tcx> Key for ty::ParamEnv<'tcx> {
334-
type CacheSelector = DefaultCacheSelector;
335-
336277
fn query_crate(&self) -> CrateNum {
337278
LOCAL_CRATE
338279
}
@@ -342,8 +283,6 @@ impl<'tcx> Key for ty::ParamEnv<'tcx> {
342283
}
343284

344285
impl<'tcx, T: Key> Key for ty::ParamEnvAnd<'tcx, T> {
345-
type CacheSelector = DefaultCacheSelector;
346-
347286
fn query_crate(&self) -> CrateNum {
348287
self.value.query_crate()
349288
}
@@ -353,8 +292,6 @@ impl<'tcx, T: Key> Key for ty::ParamEnvAnd<'tcx, T> {
353292
}
354293

355294
impl Key for Symbol {
356-
type CacheSelector = DefaultCacheSelector;
357-
358295
fn query_crate(&self) -> CrateNum {
359296
LOCAL_CRATE
360297
}
@@ -366,8 +303,6 @@ impl Key for Symbol {
366303
/// Canonical query goals correspond to abstract trait operations that
367304
/// are not tied to any crate in particular.
368305
impl<'tcx, T> Key for Canonical<'tcx, T> {
369-
type CacheSelector = DefaultCacheSelector;
370-
371306
fn query_crate(&self) -> CrateNum {
372307
LOCAL_CRATE
373308
}
@@ -378,8 +313,6 @@ impl<'tcx, T> Key for Canonical<'tcx, T> {
378313
}
379314

380315
impl Key for (Symbol, u32, u32) {
381-
type CacheSelector = DefaultCacheSelector;
382-
383316
fn query_crate(&self) -> CrateNum {
384317
LOCAL_CRATE
385318
}
@@ -390,8 +323,6 @@ impl Key for (Symbol, u32, u32) {
390323
}
391324

392325
impl<'tcx> Key for (DefId, Ty<'tcx>, SubstsRef<'tcx>, ty::ParamEnv<'tcx>) {
393-
type CacheSelector = DefaultCacheSelector;
394-
395326
fn query_crate(&self) -> CrateNum {
396327
LOCAL_CRATE
397328
}

compiler/rustc_middle/src/ty/query/plumbing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ macro_rules! is_eval_always {
263263

264264
macro_rules! query_storage {
265265
([][$K:ty, $V:ty]) => {
266-
<<$K as Key>::CacheSelector as CacheSelector<$K, $V>>::Cache
266+
<DefaultCacheSelector as CacheSelector<$K, $V>>::Cache
267267
};
268268
([storage($ty:ty) $($rest:tt)*][$K:ty, $V:ty]) => {
269269
<$ty as CacheSelector<$K, $V>>::Cache

0 commit comments

Comments
 (0)