@@ -234,18 +234,73 @@ macro_rules! hash_result {
234
234
235
235
macro_rules! define_queries {
236
236
( <$tcx: tt> $( $category: tt {
237
- $( $( #[ $attr: meta] ) * [ $( $modifiers: tt) * ] fn $name: ident: $node: ident( $K : ty ) -> $V: ty, ) *
237
+ $( $( #[ $attr: meta] ) * [ $( $modifiers: tt) * ] fn $name: ident: $node: ident( $( $K : tt ) * ) -> $V: ty, ) *
238
238
} , ) * ) => {
239
239
define_queries_inner! { <$tcx>
240
- $( $( $( #[ $attr] ) * category<$category> [ $( $modifiers) * ] fn $name: $node( $K ) -> $V, ) * ) *
240
+ $( $( $( #[ $attr] ) * category<$category> [ $( $modifiers) * ] fn $name: $node( $( $K ) * ) -> $V, ) * ) *
241
241
}
242
242
}
243
243
}
244
244
245
+ macro_rules! define_query_helper {
246
+ ( TyCtxtAt <$tcx: tt>, $( #[ $attr: meta] ) * $name: ident( DefId ) -> $V: ty) => {
247
+ $( #[ $attr] ) *
248
+ #[ inline( always) ]
249
+ pub fn $name( self , key: impl Into <DefId >) -> $V {
250
+ fn mono( this: TyCtxtAt <$tcx>, key: DefId ) -> $V {
251
+ get_query:: <queries:: $name<' _>, _>( this. tcx, this. span, key)
252
+ }
253
+
254
+ mono( self , key. into( ) )
255
+ }
256
+ } ;
257
+ ( TyCtxtAt <$tcx: tt>, $( #[ $attr: meta] ) * $name: ident( $K: ty) -> $V: ty) => {
258
+ $( #[ $attr] ) *
259
+ #[ inline( always) ]
260
+ pub fn $name( self , key: $K) -> $V {
261
+ get_query:: <queries:: $name<' _>, _>( self . tcx, self . span, key)
262
+ }
263
+ } ;
264
+
265
+ ( TyCtxt <$tcx: tt>, $( #[ $attr: meta] ) * $name: ident( DefId ) -> $V: ty) => {
266
+ $( #[ $attr] ) *
267
+ #[ inline( always) ]
268
+ pub fn $name( self , key: impl Into <DefId >) -> $V {
269
+ self . at( DUMMY_SP ) . $name( key)
270
+ }
271
+ } ;
272
+ ( TyCtxt <$tcx: tt>, $( #[ $attr: meta] ) * $name: ident( $K: ty) -> $V: ty) => {
273
+ $( #[ $attr] ) *
274
+ #[ inline( always) ]
275
+ pub fn $name( self , key: $K) -> $V {
276
+ self . at( DUMMY_SP ) . $name( key)
277
+ }
278
+ } ;
279
+
280
+ ( TyCtxtEnsure <$tcx: tt>, $( #[ $attr: meta] ) * $name: ident( DefId ) -> $V: ty) => {
281
+ $( #[ $attr] ) *
282
+ #[ inline( always) ]
283
+ pub fn $name( self , key: impl Into <DefId >) {
284
+ fn mono( this: TyCtxtEnsure <$tcx>, key: DefId ) {
285
+ ensure_query:: <queries:: $name<' _>, _>( this. tcx, key)
286
+ }
287
+
288
+ mono( self , key. into( ) )
289
+ }
290
+ } ;
291
+ ( TyCtxtEnsure <$tcx: tt>, $( #[ $attr: meta] ) * $name: ident( $K: ty) -> $V: ty) => {
292
+ $( #[ $attr] ) *
293
+ #[ inline( always) ]
294
+ pub fn $name( self , key: $K) {
295
+ ensure_query:: <queries:: $name<' _>, _>( self . tcx, key)
296
+ }
297
+ } ;
298
+ }
299
+
245
300
macro_rules! define_queries_inner {
246
301
( <$tcx: tt>
247
302
$( $( #[ $attr: meta] ) * category<$category: tt>
248
- [ $( $modifiers: tt) * ] fn $name: ident: $node: ident( $K : ty ) -> $V: ty, ) * ) => {
303
+ [ $( $modifiers: tt) * ] fn $name: ident: $node: ident( $( $K : tt ) * ) -> $V: ty, ) * ) => {
249
304
250
305
use std:: mem;
251
306
use crate :: {
@@ -263,7 +318,7 @@ macro_rules! define_queries_inner {
263
318
#[ allow( nonstandard_style) ]
264
319
#[ derive( Clone , Debug ) ]
265
320
pub enum Query <$tcx> {
266
- $( $( #[ $attr] ) * $name( $K ) ) ,*
321
+ $( $( #[ $attr] ) * $name( $( $K ) * ) ) ,*
267
322
}
268
323
269
324
impl <$tcx> Query <$tcx> {
@@ -321,7 +376,7 @@ macro_rules! define_queries_inner {
321
376
}
322
377
323
378
$( impl <$tcx> QueryConfig <TyCtxt <$tcx>> for queries:: $name<$tcx> {
324
- type Key = $K ;
379
+ type Key = $( $K ) * ;
325
380
type Value = $V;
326
381
const NAME : & ' static str = stringify!( $name) ;
327
382
const CATEGORY : ProfileCategory = $category;
@@ -332,7 +387,7 @@ macro_rules! define_queries_inner {
332
387
const EVAL_ALWAYS : bool = is_eval_always!( [ $( $modifiers) * ] ) ;
333
388
const DEP_KIND : dep_graph:: DepKind = dep_graph:: DepKind :: $node;
334
389
335
- type Cache = query_storage!( [ $( $modifiers) * ] [ $K , $V] ) ;
390
+ type Cache = query_storage!( [ $( $modifiers) * ] [ $( $K ) * , $V] ) ;
336
391
337
392
#[ inline( always) ]
338
393
fn query_state<' a>( tcx: TyCtxt <$tcx>) -> & ' a QueryState <TyCtxt <$tcx>, Self :: Cache > {
@@ -377,12 +432,8 @@ macro_rules! define_queries_inner {
377
432
pub tcx: TyCtxt <' tcx>,
378
433
}
379
434
380
- impl TyCtxtEnsure <$tcx> {
381
- $( $( #[ $attr] ) *
382
- #[ inline( always) ]
383
- pub fn $name( self , key: $K) {
384
- ensure_query:: <queries:: $name<' _>, _>( self . tcx, key)
385
- } ) *
435
+ impl TyCtxtEnsure <' tcx> {
436
+ $( define_query_helper!( TyCtxtEnsure <' tcx>, $( #[ $attr] ) * $name( $( $K) * ) -> $V) ; ) *
386
437
}
387
438
388
439
#[ derive( Copy , Clone ) ]
@@ -419,11 +470,7 @@ macro_rules! define_queries_inner {
419
470
}
420
471
}
421
472
422
- $( $( #[ $attr] ) *
423
- #[ inline( always) ]
424
- pub fn $name( self , key: $K) -> $V {
425
- self . at( DUMMY_SP ) . $name( key)
426
- } ) *
473
+ $( define_query_helper!( TyCtxt <$tcx>, $( #[ $attr] ) * $name( $( $K) * ) -> $V) ; ) *
427
474
428
475
/// All self-profiling events generated by the query engine use
429
476
/// virtual `StringId`s for their `event_id`. This method makes all
@@ -456,16 +503,12 @@ macro_rules! define_queries_inner {
456
503
}
457
504
458
505
impl TyCtxtAt <$tcx> {
459
- $( $( #[ $attr] ) *
460
- #[ inline( always) ]
461
- pub fn $name( self , key: $K) -> $V {
462
- get_query:: <queries:: $name<' _>, _>( self . tcx, self . span, key)
463
- } ) *
506
+ $( define_query_helper!( TyCtxtAt <$tcx>, $( #[ $attr] ) * $name( $( $K) * ) -> $V) ; ) *
464
507
}
465
508
466
509
define_provider_struct! {
467
510
tcx: $tcx,
468
- input: ( $( ( [ $( $modifiers) * ] [ $name] [ $K ] [ $V] ) ) * )
511
+ input: ( $( ( [ $( $modifiers) * ] [ $name] [ $( $K ) * ] [ $V] ) ) * )
469
512
}
470
513
471
514
impl <$tcx> Copy for Providers <$tcx> { }
0 commit comments