@@ -15,6 +15,7 @@ use crate::mir::interpret::{
1515} ;
1616use crate :: mir:: interpret:: { LitToConstError , LitToConstInput } ;
1717use crate :: mir:: mono:: CodegenUnit ;
18+ use crate :: query:: Key ;
1819use crate :: thir;
1920use crate :: traits:: query:: {
2021 CanonicalPredicateGoal , CanonicalProjectionGoal , CanonicalTyGoal ,
@@ -120,17 +121,15 @@ macro_rules! query_helper_param_ty {
120121}
121122
122123macro_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+ } ;
134133}
135134
136135macro_rules! separate_provide_extern_decl {
0 commit comments