@@ -301,11 +301,8 @@ pub(crate) fn create_query_frame<
301301 QueryStackFrame :: new ( name, description, span, def_kind, hash)
302302}
303303
304- pub ( crate ) fn try_load_from_on_disk_cache < ' tcx , Q , V > (
305- tcx : TyCtxt < ' tcx > ,
306- dep_node : DepNode ,
307- cache_query_deps : fn ( TyCtxt < ' tcx > , Q :: Key ) -> V ,
308- ) where
304+ fn try_load_from_on_disk_cache < ' tcx , Q > ( tcx : TyCtxt < ' tcx > , dep_node : DepNode )
305+ where
309306 Q : QueryDescription < QueryCtxt < ' tcx > > ,
310307 Q :: Key : DepNodeParams < TyCtxt < ' tcx > > ,
311308{
@@ -315,11 +312,11 @@ pub(crate) fn try_load_from_on_disk_cache<'tcx, Q, V>(
315312 panic ! ( "Failed to recover key for {:?} with hash {}" , dep_node, dep_node. hash)
316313 } ) ;
317314 if Q :: cache_on_disk ( tcx, & key) {
318- let _ = cache_query_deps ( tcx, key) ;
315+ let _ = Q :: execute_query ( tcx, key) ;
319316 }
320317}
321318
322- pub ( crate ) fn force_from_dep_node < ' tcx , Q > ( tcx : TyCtxt < ' tcx > , dep_node : DepNode ) -> bool
319+ fn force_from_dep_node < ' tcx , Q > ( tcx : TyCtxt < ' tcx > , dep_node : DepNode ) -> bool
323320where
324321 Q : QueryDescription < QueryCtxt < ' tcx > > ,
325322 Q :: Key : DepNodeParams < TyCtxt < ' tcx > > ,
@@ -336,13 +333,9 @@ where
336333}
337334
338335pub ( crate ) fn query_callback < ' tcx , Q : QueryConfig > (
339- // NOTE: we can't remove these function pointers, because `recover` is invariant -> `try_load_from_on_disk_cache` takes a concrete lifetime, not a universal lifetime.
340- // Instead, we infer the correct lifetime at the callsite, so we can pass in a HRTB function pointer to the DepKindStruct.
341- try_load_from_on_disk_cache : fn ( TyCtxt < ' _ > , DepNode ) ,
342- force_from_dep_node : fn ( TyCtxt < ' _ > , DepNode ) -> bool ,
343336 is_anon : bool ,
344337 is_eval_always : bool ,
345- ) -> DepKindStruct
338+ ) -> DepKindStruct < ' tcx >
346339where
347340 Q : QueryDescription < QueryCtxt < ' tcx > > ,
348341 Q :: Key : DepNodeParams < TyCtxt < ' tcx > > ,
@@ -363,8 +356,8 @@ where
363356 is_anon,
364357 is_eval_always,
365358 fingerprint_style,
366- force_from_dep_node : Some ( force_from_dep_node) ,
367- try_load_from_on_disk_cache : Some ( try_load_from_on_disk_cache) ,
359+ force_from_dep_node : Some ( force_from_dep_node :: < Q > ) ,
360+ try_load_from_on_disk_cache : Some ( try_load_from_on_disk_cache :: < Q > ) ,
368361 }
369362}
370363
@@ -431,6 +424,10 @@ macro_rules! define_queries {
431424 try_load_from_disk: Self :: TRY_LOAD_FROM_DISK ,
432425 }
433426 }
427+
428+ fn execute_query( tcx: TyCtxt <' tcx>, k: Self :: Key ) -> Self :: Stored {
429+ tcx. $name( k)
430+ }
434431 } ) *
435432
436433 #[ allow( nonstandard_style) ]
@@ -439,7 +436,7 @@ macro_rules! define_queries {
439436 use rustc_query_system:: dep_graph:: FingerprintStyle ;
440437
441438 // We use this for most things when incr. comp. is turned off.
442- pub fn Null ( ) -> DepKindStruct {
439+ pub fn Null < ' tcx> ( ) -> DepKindStruct < ' tcx> {
443440 DepKindStruct {
444441 is_anon: false ,
445442 is_eval_always: false ,
@@ -450,7 +447,7 @@ macro_rules! define_queries {
450447 }
451448
452449 // We use this for the forever-red node.
453- pub fn Red ( ) -> DepKindStruct {
450+ pub fn Red < ' tcx> ( ) -> DepKindStruct < ' tcx> {
454451 DepKindStruct {
455452 is_anon: false ,
456453 is_eval_always: false ,
@@ -460,7 +457,7 @@ macro_rules! define_queries {
460457 }
461458 }
462459
463- pub fn TraitSelect ( ) -> DepKindStruct {
460+ pub fn TraitSelect < ' tcx> ( ) -> DepKindStruct < ' tcx> {
464461 DepKindStruct {
465462 is_anon: true ,
466463 is_eval_always: false ,
@@ -470,7 +467,7 @@ macro_rules! define_queries {
470467 }
471468 }
472469
473- pub fn CompileCodegenUnit ( ) -> DepKindStruct {
470+ pub fn CompileCodegenUnit < ' tcx> ( ) -> DepKindStruct < ' tcx> {
474471 DepKindStruct {
475472 is_anon: false ,
476473 is_eval_always: false ,
@@ -480,7 +477,7 @@ macro_rules! define_queries {
480477 }
481478 }
482479
483- pub fn CompileMonoItem ( ) -> DepKindStruct {
480+ pub fn CompileMonoItem < ' tcx> ( ) -> DepKindStruct < ' tcx> {
484481 DepKindStruct {
485482 is_anon: false ,
486483 is_eval_always: false ,
@@ -490,21 +487,15 @@ macro_rules! define_queries {
490487 }
491488 }
492489
493- $( pub ( crate ) fn $name( ) -> DepKindStruct {
494- let is_anon = is_anon!( [ $( $modifiers) * ] ) ;
495- let is_eval_always = is_eval_always!( [ $( $modifiers) * ] ) ;
496- type Q <' tcx> = queries:: $name<' tcx>;
497-
498- $crate:: plumbing:: query_callback:: <Q <' _>>(
499- |tcx, key| $crate:: plumbing:: try_load_from_on_disk_cache:: <Q <' _>, _>( tcx, key, TyCtxt :: $name) ,
500- |tcx, key| $crate:: plumbing:: force_from_dep_node:: <Q <' _>>( tcx, key) ,
501- is_anon,
502- is_eval_always
490+ $( pub ( crate ) fn $name<' tcx>( ) -> DepKindStruct <' tcx> {
491+ $crate:: plumbing:: query_callback:: <queries:: $name<' tcx>>(
492+ is_anon!( [ $( $modifiers) * ] ) ,
493+ is_eval_always!( [ $( $modifiers) * ] ) ,
503494 )
504495 } ) *
505496 }
506497
507- pub fn query_callbacks<' tcx>( arena: & ' tcx Arena <' tcx>) -> & ' tcx [ DepKindStruct ] {
498+ pub fn query_callbacks<' tcx>( arena: & ' tcx Arena <' tcx>) -> & ' tcx [ DepKindStruct < ' tcx> ] {
508499 arena. alloc_from_iter( make_dep_kind_array!( query_callbacks) )
509500 }
510501 }
0 commit comments