@@ -382,17 +382,21 @@ where
382382}
383383
384384#[ inline( always) ]
385- fn try_execute_query < Q , CTX > (
385+ fn try_execute_query < CTX , C > (
386386 tcx : CTX ,
387+ state : & QueryState < CTX , C > ,
387388 span : Span ,
388- key : Q :: Key ,
389- lookup : QueryLookup < ' _ , CTX , Q :: Key , <Q :: Cache as QueryCache >:: Sharded > ,
390- ) -> Q :: Stored
389+ key : C :: Key ,
390+ lookup : QueryLookup < ' _ , CTX , C :: Key , C :: Sharded > ,
391+ query : & QueryVtable < CTX , C :: Key , C :: Value > ,
392+ ) -> C :: Stored
391393where
392- Q : QueryDescription < CTX > ,
394+ C : QueryCache ,
395+ C :: Key : Eq + Clone + Debug ,
396+ C :: Stored : Clone ,
393397 CTX : QueryContext ,
394398{
395- let job = match JobOwner :: try_start ( tcx, Q :: query_state ( tcx ) , span, & key, lookup, & Q :: VTABLE ) {
399+ let job = match JobOwner :: try_start ( tcx, state , span, & key, lookup, query ) {
396400 TryGetJob :: NotYetStarted ( job) => job,
397401 TryGetJob :: Cycle ( result) => return result,
398402 #[ cfg( parallel_compiler) ]
@@ -406,18 +410,32 @@ where
406410 // expensive for some `DepKind`s.
407411 if !tcx. dep_graph ( ) . is_fully_enabled ( ) {
408412 let null_dep_node = DepNode :: new_no_params ( DepKind :: NULL ) ;
409- return force_query_with_job ( tcx, key, job, null_dep_node, & Q :: VTABLE ) . 0 ;
413+ return force_query_with_job ( tcx, key, job, null_dep_node, query ) . 0 ;
410414 }
411415
412- if Q :: ANON {
413- let ( result, dep_node_index) = try_execute_anon_query ( tcx, key, job. id , & Q :: VTABLE ) ;
416+ if query. anon {
417+ let prof_timer = tcx. profiler ( ) . query_provider ( ) ;
418+
419+ let ( ( result, dep_node_index) , diagnostics) = with_diagnostics ( |diagnostics| {
420+ tcx. start_query ( job. id , diagnostics, |tcx| {
421+ tcx. dep_graph ( ) . with_anon_task ( query. dep_kind , || query. compute ( tcx, key) )
422+ } )
423+ } ) ;
424+
425+ prof_timer. finish_with_query_invocation_id ( dep_node_index. into ( ) ) ;
426+
427+ tcx. dep_graph ( ) . read_index ( dep_node_index) ;
428+
429+ if unlikely ! ( !diagnostics. is_empty( ) ) {
430+ tcx. store_diagnostics_for_anon_node ( dep_node_index, diagnostics) ;
431+ }
414432
415433 return job. complete ( tcx, result, dep_node_index) ;
416434 }
417435
418- let dep_node = Q :: to_dep_node ( tcx, & key) ;
436+ let dep_node = query . to_dep_node ( tcx, & key) ;
419437
420- if !Q :: EVAL_ALWAYS {
438+ if !query . eval_always {
421439 // The diagnostics for this query will be
422440 // promoted to the current session during
423441 // `try_mark_green()`, so we can ignore them here.
@@ -431,7 +449,7 @@ where
431449 prev_dep_node_index,
432450 dep_node_index,
433451 & dep_node,
434- & Q :: VTABLE ,
452+ query ,
435453 ) ,
436454 dep_node_index,
437455 )
@@ -442,40 +460,11 @@ where
442460 }
443461 }
444462
445- let ( result, dep_node_index) = force_query_with_job ( tcx, key, job, dep_node, & Q :: VTABLE ) ;
463+ let ( result, dep_node_index) = force_query_with_job ( tcx, key, job, dep_node, query ) ;
446464 tcx. dep_graph ( ) . read_index ( dep_node_index) ;
447465 result
448466}
449467
450- fn try_execute_anon_query < CTX , K , V > (
451- tcx : CTX ,
452- key : K ,
453- job_id : QueryJobId < CTX :: DepKind > ,
454- query : & QueryVtable < CTX , K , V > ,
455- ) -> ( V , DepNodeIndex )
456- where
457- CTX : QueryContext ,
458- {
459- debug_assert ! ( query. anon) ;
460- let prof_timer = tcx. profiler ( ) . query_provider ( ) ;
461-
462- let ( ( result, dep_node_index) , diagnostics) = with_diagnostics ( |diagnostics| {
463- tcx. start_query ( job_id, diagnostics, |tcx| {
464- tcx. dep_graph ( ) . with_anon_task ( query. dep_kind , || query. compute ( tcx, key) )
465- } )
466- } ) ;
467-
468- prof_timer. finish_with_query_invocation_id ( dep_node_index. into ( ) ) ;
469-
470- tcx. dep_graph ( ) . read_index ( dep_node_index) ;
471-
472- if unlikely ! ( !diagnostics. is_empty( ) ) {
473- tcx. store_diagnostics_for_anon_node ( dep_node_index, diagnostics) ;
474- }
475-
476- ( result, dep_node_index)
477- }
478-
479468fn load_from_disk_and_cache_in_memory < CTX , K , V > (
480469 tcx : CTX ,
481470 key : K ,
@@ -639,7 +628,7 @@ where
639628 tcx. dep_graph ( ) . read_index ( index) ;
640629 value. clone ( )
641630 } ,
642- |key, lookup| try_execute_query :: < Q , _ > ( tcx, span, key, lookup) ,
631+ |key, lookup| try_execute_query ( tcx , Q :: query_state ( tcx) , span, key, lookup, & Q :: VTABLE ) ,
643632 )
644633}
645634
0 commit comments