@@ -242,59 +242,9 @@ macro_rules! define_queries {
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
- } ;
245
+ macro_rules! query_helper_param_ty {
246
+ ( DefId ) => { impl Into <DefId > } ;
247
+ ( $K: ty) => { $K } ;
298
248
}
299
249
300
250
macro_rules! define_queries_inner {
@@ -432,8 +382,12 @@ macro_rules! define_queries_inner {
432
382
pub tcx: TyCtxt <' tcx>,
433
383
}
434
384
435
- impl TyCtxtEnsure <' tcx> {
436
- $( define_query_helper!( TyCtxtEnsure <' tcx>, $( #[ $attr] ) * $name( $( $K) * ) -> $V) ; ) *
385
+ impl TyCtxtEnsure <$tcx> {
386
+ $( $( #[ $attr] ) *
387
+ #[ inline( always) ]
388
+ pub fn $name( self , key: query_helper_param_ty!( $( $K) * ) ) {
389
+ ensure_query:: <queries:: $name<' _>, _>( self . tcx, key. into( ) )
390
+ } ) *
437
391
}
438
392
439
393
#[ derive( Copy , Clone ) ]
@@ -470,7 +424,11 @@ macro_rules! define_queries_inner {
470
424
}
471
425
}
472
426
473
- $( define_query_helper!( TyCtxt <$tcx>, $( #[ $attr] ) * $name( $( $K) * ) -> $V) ; ) *
427
+ $( $( #[ $attr] ) *
428
+ #[ inline( always) ]
429
+ pub fn $name( self , key: query_helper_param_ty!( $( $K) * ) ) -> $V {
430
+ self . at( DUMMY_SP ) . $name( key)
431
+ } ) *
474
432
475
433
/// All self-profiling events generated by the query engine use
476
434
/// virtual `StringId`s for their `event_id`. This method makes all
@@ -503,7 +461,11 @@ macro_rules! define_queries_inner {
503
461
}
504
462
505
463
impl TyCtxtAt <$tcx> {
506
- $( define_query_helper!( TyCtxtAt <$tcx>, $( #[ $attr] ) * $name( $( $K) * ) -> $V) ; ) *
464
+ $( $( #[ $attr] ) *
465
+ #[ inline( always) ]
466
+ pub fn $name( self , key: query_helper_param_ty!( $( $K) * ) ) -> $V {
467
+ get_query:: <queries:: $name<' _>, _>( self . tcx, self . span, key. into( ) )
468
+ } ) *
507
469
}
508
470
509
471
define_provider_struct! {
0 commit comments