@@ -15,6 +15,7 @@ use crate::mir::interpret::{
15
15
} ;
16
16
use crate :: mir:: interpret:: { LitToConstError , LitToConstInput } ;
17
17
use crate :: mir:: mono:: CodegenUnit ;
18
+ use crate :: query:: Key ;
18
19
use crate :: thir;
19
20
use crate :: traits:: query:: {
20
21
CanonicalPredicateGoal , CanonicalProjectionGoal , CanonicalTyGoal ,
@@ -120,17 +121,15 @@ macro_rules! query_helper_param_ty {
120
121
}
121
122
122
123
macro_rules! query_storage {
123
- // FIXME(cjgillot) this macro-based way to perform type-based dispatch is clearly brittle.
124
- // It should probably be replaced by an associated type on the `Key` trait.
125
- ( [ ] [ CrateNum , $V: ty] ) => { VecCache <CrateNum , $V> } ;
126
- ( [ ( arena_cache) $( $rest: tt) * ] [ CrateNum , $V: ty] ) => { VecArenaCache <' tcx, CrateNum , $V> } ;
127
- ( [ ] [ LocalDefId , $V: ty] ) => { VecCache <LocalDefId , $V> } ;
128
- ( [ ( arena_cache) $( $rest: tt) * ] [ LocalDefId , $V: ty] ) => { VecArenaCache <' tcx, LocalDefId , $V> } ;
129
- ( [ ] [ hir:: OwnerId , $V: ty] ) => { VecCache <hir:: OwnerId , $V> } ;
130
- ( [ ( arena_cache) $( $rest: tt) * ] [ hir:: OwnerId , $V: ty] ) => { VecArenaCache <' tcx, hir:: OwnerId , $V> } ;
131
- ( [ ] [ $K: ty, $V: ty] ) => { DefaultCache <$K, $V> } ;
132
- ( [ ( arena_cache) $( $rest: tt) * ] [ $K: ty, $V: ty] ) => { ArenaCache <' tcx, $K, $V> } ;
133
- ( [ $other: tt $( $modifiers: tt) * ] [ $( $args: tt) * ] ) => { query_storage!( [ $( $modifiers) * ] [ $( $args) * ] ) } ;
124
+ ( [ ] [ $K: ty, $V: ty] ) => {
125
+ <<$K as Key >:: CacheSelector as CacheSelector <' tcx, $V>>:: Cache
126
+ } ;
127
+ ( [ ( arena_cache) $( $rest: tt) * ] [ $K: ty, $V: ty] ) => {
128
+ <<$K as Key >:: CacheSelector as CacheSelector <' tcx, $V>>:: ArenaCache
129
+ } ;
130
+ ( [ $other: tt $( $modifiers: tt) * ] [ $( $args: tt) * ] ) => {
131
+ query_storage!( [ $( $modifiers) * ] [ $( $args) * ] )
132
+ } ;
134
133
}
135
134
136
135
macro_rules! separate_provide_extern_decl {
0 commit comments