@@ -36,6 +36,8 @@ pub trait QueryKey: Sized + QueryKeyBounds {
3636 /// [`QueryCache`]: rustc_middle::query::QueryCache
3737 type Cache < V > = DefaultCache < Self , V > ;
3838
39+ type LocalQueryKey = !;
40+
3941 /// In the event that a cycle occurs, if no explicit span has been
4042 /// given for a query with key `self`, what span should we use?
4143 fn default_span ( & self , tcx : TyCtxt < ' _ > ) -> Span ;
@@ -45,14 +47,12 @@ pub trait QueryKey: Sized + QueryKeyBounds {
4547 fn key_as_def_id ( & self ) -> Option < DefId > {
4648 None
4749 }
48- }
49-
50- pub trait AsLocalQueryKey : QueryKey {
51- type LocalQueryKey ;
5250
5351 /// Given an instance of this key, what crate is it referring to?
5452 /// This is used to find the provider.
55- fn as_local_key ( & self ) -> Option < Self :: LocalQueryKey > ;
53+ fn as_local_key ( & self ) -> Option < Self :: LocalQueryKey > {
54+ None
55+ }
5656}
5757
5858impl QueryKey for ( ) {
@@ -96,13 +96,11 @@ impl<'tcx> QueryKey for ty::LitToConstInput<'tcx> {
9696impl QueryKey for CrateNum {
9797 type Cache < V > = VecCache < Self , V , DepNodeIndex > ;
9898
99+ type LocalQueryKey = LocalCrate ;
100+
99101 fn default_span ( & self , _: TyCtxt < ' _ > ) -> Span {
100102 DUMMY_SP
101103 }
102- }
103-
104- impl AsLocalQueryKey for CrateNum {
105- type LocalQueryKey = LocalCrate ;
106104
107105 #[ inline( always) ]
108106 fn as_local_key ( & self ) -> Option < Self :: LocalQueryKey > {
@@ -136,6 +134,7 @@ impl QueryKey for LocalDefId {
136134
137135impl QueryKey for DefId {
138136 type Cache < V > = DefIdCache < V > ;
137+ type LocalQueryKey = LocalDefId ;
139138
140139 fn default_span ( & self , tcx : TyCtxt < ' _ > ) -> Span {
141140 tcx. def_span ( * self )
@@ -145,10 +144,6 @@ impl QueryKey for DefId {
145144 fn key_as_def_id ( & self ) -> Option < DefId > {
146145 Some ( * self )
147146 }
148- }
149-
150- impl AsLocalQueryKey for DefId {
151- type LocalQueryKey = LocalDefId ;
152147
153148 #[ inline( always) ]
154149 fn as_local_key ( & self ) -> Option < Self :: LocalQueryKey > {
@@ -197,13 +192,11 @@ impl QueryKey for (LocalDefId, LocalDefId, Ident) {
197192}
198193
199194impl QueryKey for ( CrateNum , DefId ) {
195+ type LocalQueryKey = DefId ;
196+
200197 fn default_span ( & self , tcx : TyCtxt < ' _ > ) -> Span {
201198 self . 1 . default_span ( tcx)
202199 }
203- }
204-
205- impl AsLocalQueryKey for ( CrateNum , DefId ) {
206- type LocalQueryKey = DefId ;
207200
208201 #[ inline( always) ]
209202 fn as_local_key ( & self ) -> Option < Self :: LocalQueryKey > {
@@ -212,13 +205,11 @@ impl AsLocalQueryKey for (CrateNum, DefId) {
212205}
213206
214207impl QueryKey for ( CrateNum , SimplifiedType ) {
208+ type LocalQueryKey = SimplifiedType ;
209+
215210 fn default_span ( & self , _: TyCtxt < ' _ > ) -> Span {
216211 DUMMY_SP
217212 }
218- }
219-
220- impl AsLocalQueryKey for ( CrateNum , SimplifiedType ) {
221- type LocalQueryKey = SimplifiedType ;
222213
223214 #[ inline( always) ]
224215 fn as_local_key ( & self ) -> Option < Self :: LocalQueryKey > {
0 commit comments