@@ -234,18 +234,23 @@ 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! query_helper_param_ty {
246
+ ( DefId ) => { impl IntoQueryParam <DefId > } ;
247
+ ( $K: ty) => { $K } ;
248
+ }
249
+
245
250
macro_rules! define_queries_inner {
246
251
( <$tcx: tt>
247
252
$( $( #[ $attr: meta] ) * category<$category: tt>
248
- [ $( $modifiers: tt) * ] fn $name: ident: $node: ident( $K : ty ) -> $V: ty, ) * ) => {
253
+ [ $( $modifiers: tt) * ] fn $name: ident: $node: ident( $( $K : tt ) * ) -> $V: ty, ) * ) => {
249
254
250
255
use std:: mem;
251
256
use crate :: {
@@ -263,7 +268,7 @@ macro_rules! define_queries_inner {
263
268
#[ allow( nonstandard_style) ]
264
269
#[ derive( Clone , Debug ) ]
265
270
pub enum Query <$tcx> {
266
- $( $( #[ $attr] ) * $name( $K ) ) ,*
271
+ $( $( #[ $attr] ) * $name( $( $K ) * ) ) ,*
267
272
}
268
273
269
274
impl <$tcx> Query <$tcx> {
@@ -321,7 +326,7 @@ macro_rules! define_queries_inner {
321
326
}
322
327
323
328
$( impl <$tcx> QueryConfig <TyCtxt <$tcx>> for queries:: $name<$tcx> {
324
- type Key = $K ;
329
+ type Key = $( $K ) * ;
325
330
type Value = $V;
326
331
const NAME : & ' static str = stringify!( $name) ;
327
332
const CATEGORY : ProfileCategory = $category;
@@ -332,7 +337,7 @@ macro_rules! define_queries_inner {
332
337
const EVAL_ALWAYS : bool = is_eval_always!( [ $( $modifiers) * ] ) ;
333
338
const DEP_KIND : dep_graph:: DepKind = dep_graph:: DepKind :: $node;
334
339
335
- type Cache = query_storage!( [ $( $modifiers) * ] [ $K , $V] ) ;
340
+ type Cache = query_storage!( [ $( $modifiers) * ] [ $( $K ) * , $V] ) ;
336
341
337
342
#[ inline( always) ]
338
343
fn query_state<' a>( tcx: TyCtxt <$tcx>) -> & ' a QueryState <TyCtxt <$tcx>, Self :: Cache > {
@@ -380,8 +385,8 @@ macro_rules! define_queries_inner {
380
385
impl TyCtxtEnsure <$tcx> {
381
386
$( $( #[ $attr] ) *
382
387
#[ inline( always) ]
383
- pub fn $name( self , key: $K ) {
384
- ensure_query:: <queries:: $name<' _>, _>( self . tcx, key)
388
+ pub fn $name( self , key: query_helper_param_ty! ( $ ( $K ) * ) ) {
389
+ ensure_query:: <queries:: $name<' _>, _>( self . tcx, key. into_query_param ( ) )
385
390
} ) *
386
391
}
387
392
@@ -421,7 +426,7 @@ macro_rules! define_queries_inner {
421
426
422
427
$( $( #[ $attr] ) *
423
428
#[ inline( always) ]
424
- pub fn $name( self , key: $K ) -> $V {
429
+ pub fn $name( self , key: query_helper_param_ty! ( $ ( $K ) * ) ) -> $V {
425
430
self . at( DUMMY_SP ) . $name( key)
426
431
} ) *
427
432
@@ -458,14 +463,14 @@ macro_rules! define_queries_inner {
458
463
impl TyCtxtAt <$tcx> {
459
464
$( $( #[ $attr] ) *
460
465
#[ inline( always) ]
461
- pub fn $name( self , key: $K ) -> $V {
462
- get_query:: <queries:: $name<' _>, _>( self . tcx, self . span, key)
466
+ pub fn $name( self , key: query_helper_param_ty! ( $ ( $K ) * ) ) -> $V {
467
+ get_query:: <queries:: $name<' _>, _>( self . tcx, self . span, key. into_query_param ( ) )
463
468
} ) *
464
469
}
465
470
466
471
define_provider_struct! {
467
472
tcx: $tcx,
468
- input: ( $( ( [ $( $modifiers) * ] [ $name] [ $K ] [ $V] ) ) * )
473
+ input: ( $( ( [ $( $modifiers) * ] [ $name] [ $( $K ) * ] [ $V] ) ) * )
469
474
}
470
475
471
476
impl <$tcx> Copy for Providers <$tcx> { }
0 commit comments