@@ -151,9 +151,13 @@ pub(crate) fn encode_all_query_results<'tcx>(
151151 encoder : & mut CacheEncoder < ' _ , ' tcx > ,
152152 query_result_index : & mut EncodedDepNodeIndex ,
153153) {
154- for_each_query_vtable ! ( CACHE_ON_DISK , tcx, |query| {
155- encode_query_results( tcx, query, encoder, query_result_index)
156- } ) ;
154+ for_each_query_vtable ! (
155+ encode_query_results,
156+ tcx,
157+ CACHE_ON_DISK_QUERIES ,
158+ encoder,
159+ query_result_index,
160+ ) ;
157161}
158162
159163fn encode_query_results < ' a , ' tcx , C , V > (
@@ -185,16 +189,14 @@ fn encode_query_results<'a, 'tcx, C, V>(
185189pub ( crate ) fn query_key_hash_verify_all < ' tcx > ( tcx : TyCtxt < ' tcx > ) {
186190 if tcx. sess . opts . unstable_opts . incremental_verify_ich || cfg ! ( debug_assertions) {
187191 tcx. sess . time ( "query_key_hash_verify_all" , || {
188- for_each_query_vtable ! ( ALL , tcx, |query| {
189- query_key_hash_verify( query, tcx) ;
190- } ) ;
192+ for_each_query_vtable ! ( query_key_hash_verify, tcx, ALL_QUERIES )
191193 } ) ;
192194 }
193195}
194196
195197fn query_key_hash_verify < ' tcx , C : QueryCache > (
196- query : & ' tcx QueryVTable < ' tcx , C > ,
197198 tcx : TyCtxt < ' tcx > ,
199+ query : & ' tcx QueryVTable < ' tcx , C > ,
198200) {
199201 let _timer = tcx. prof . generic_activity_with_arg ( "query_key_hash_verify_for" , query. name ) ;
200202
@@ -532,10 +534,15 @@ macro_rules! define_queries {
532534 }
533535 }
534536
535- /// Given a filter condition (e.g. `ALL` or `CACHE_ON_DISK`), a `tcx`,
536- /// and a closure expression that accepts `&QueryVTable`, this macro
537- /// calls that closure with each query vtable that satisfies the filter
538- /// condition.
537+ /// Given a function name, a `tcx`, and a filter condition
538+ /// (e.g. `ALL_QUERIES` or `CACHE_ON_DISK_QUERIES`),
539+ /// this macro calls that function with each query vtable that satisfies
540+ /// the filter condition.
541+ ///
542+ /// The arguments passed to each function call are:
543+ /// - `tcx`
544+ /// - A query vtable that satisfies the filter condition
545+ /// - All other arguments given after the filter condition
539546 ///
540547 /// This needs to be a macro, because the vtables can have different
541548 /// key/value/cache types for different queries.
@@ -548,30 +555,32 @@ macro_rules! define_queries {
548555 /// implemented by hand as needed.
549556 macro_rules! for_each_query_vtable {
550557 // Call with all queries.
551- ( ALL , $tcx: expr, $closure : expr) => { {
558+ ( $inner_fn : expr , $tcx: expr, ALL_QUERIES $$ ( , $args : expr) * $$ ( , ) ? ) => { {
552559 let tcx: rustc_middle:: ty:: TyCtxt <' _> = $tcx;
553560 $(
554- let query: & rustc_middle:: query:: plumbing:: QueryVTable <' _, _> =
555- & tcx. query_system. query_vtables. $name;
556- $closure( query) ;
561+ $inner_fn(
562+ tcx,
563+ & tcx. query_system. query_vtables. $name,
564+ $$( $args) ,*
565+ ) ;
557566 ) *
558567 } } ;
559568
560569 // Only call with queries that can potentially cache to disk.
561570 //
562571 // This allows the use of trait bounds that only need to be satisfied
563572 // by the subset of queries that actually cache to disk.
564- ( CACHE_ON_DISK , $tcx: expr, $closure : expr) => { {
573+ ( $inner_fn : expr , $tcx: expr, CACHE_ON_DISK_QUERIES $$ ( , $args : expr) * $$ ( , ) ? ) => { {
565574 let tcx: rustc_middle:: ty:: TyCtxt <' _> = $tcx;
566575 $(
567576 #[ cfg( $cache_on_disk) ]
568- {
569- let query : & rustc_middle :: query :: plumbing :: QueryVTable < ' _ , _> =
570- & tcx. query_system. query_vtables. $name;
571- $closure ( query ) ;
572- }
577+ $inner_fn (
578+ tcx ,
579+ & tcx. query_system. query_vtables. $name,
580+ $$ ( $args ) , *
581+ ) ;
573582 ) *
574- } }
583+ } } ;
575584 }
576585
577586 pub ( crate ) use for_each_query_vtable;
0 commit comments