@@ -382,7 +382,6 @@ fn try_execute_query<CTX, C>(
382382 lookup : QueryLookup ,
383383 dep_node : Option < DepNode < CTX :: DepKind > > ,
384384 query : & QueryVtable < CTX , C :: Key , C :: Value > ,
385- compute : fn ( CTX :: DepContext , C :: Key ) -> C :: Value ,
386385) -> ( C :: Stored , Option < DepNodeIndex > )
387386where
388387 C : QueryCache ,
@@ -398,7 +397,7 @@ where
398397 query. dep_kind ,
399398 ) {
400399 TryGetJob :: NotYetStarted ( job) => {
401- let ( result, dep_node_index) = execute_job ( tcx, key, dep_node, query, job. id , compute ) ;
400+ let ( result, dep_node_index) = execute_job ( tcx, key, dep_node, query, job. id ) ;
402401 let result = job. complete ( cache, result, dep_node_index) ;
403402 ( result, Some ( dep_node_index) )
404403 }
@@ -429,7 +428,6 @@ fn execute_job<CTX, K, V>(
429428 mut dep_node_opt : Option < DepNode < CTX :: DepKind > > ,
430429 query : & QueryVtable < CTX , K , V > ,
431430 job_id : QueryJobId < CTX :: DepKind > ,
432- compute : fn ( CTX :: DepContext , K ) -> V ,
433431) -> ( V , DepNodeIndex )
434432where
435433 K : Clone + DepNodeParams < CTX :: DepContext > ,
@@ -441,7 +439,7 @@ where
441439 // Fast path for when incr. comp. is off.
442440 if !dep_graph. is_fully_enabled ( ) {
443441 let prof_timer = tcx. dep_context ( ) . profiler ( ) . query_provider ( ) ;
444- let result = tcx. start_query ( job_id, None , || compute ( * tcx. dep_context ( ) , key) ) ;
442+ let result = tcx. start_query ( job_id, None , || query . compute ( * tcx. dep_context ( ) , key) ) ;
445443 let dep_node_index = dep_graph. next_virtual_depnode_index ( ) ;
446444 prof_timer. finish_with_query_invocation_id ( dep_node_index. into ( ) ) ;
447445 return ( result, dep_node_index) ;
@@ -455,7 +453,7 @@ where
455453 // The diagnostics for this query will be promoted to the current session during
456454 // `try_mark_green()`, so we can ignore them here.
457455 if let Some ( ret) = tcx. start_query ( job_id, None , || {
458- try_load_from_disk_and_cache_in_memory ( tcx, & key, & dep_node, query, compute )
456+ try_load_from_disk_and_cache_in_memory ( tcx, & key, & dep_node, query)
459457 } ) {
460458 return ret;
461459 }
@@ -467,14 +465,14 @@ where
467465 let ( result, dep_node_index) = tcx. start_query ( job_id, Some ( & diagnostics) , || {
468466 if query. anon {
469467 return dep_graph. with_anon_task ( * tcx. dep_context ( ) , query. dep_kind , || {
470- compute ( * tcx. dep_context ( ) , key)
468+ query . compute ( * tcx. dep_context ( ) , key)
471469 } ) ;
472470 }
473471
474472 // `to_dep_node` is expensive for some `DepKind`s.
475473 let dep_node = dep_node_opt. unwrap_or_else ( || query. to_dep_node ( * tcx. dep_context ( ) , & key) ) ;
476474
477- dep_graph. with_task ( dep_node, * tcx. dep_context ( ) , key, compute, query. hash_result )
475+ dep_graph. with_task ( dep_node, * tcx. dep_context ( ) , key, query . compute , query. hash_result )
478476 } ) ;
479477
480478 prof_timer. finish_with_query_invocation_id ( dep_node_index. into ( ) ) ;
@@ -498,7 +496,6 @@ fn try_load_from_disk_and_cache_in_memory<CTX, K, V>(
498496 key : & K ,
499497 dep_node : & DepNode < CTX :: DepKind > ,
500498 query : & QueryVtable < CTX , K , V > ,
501- compute : fn ( CTX :: DepContext , K ) -> V ,
502499) -> Option < ( V , DepNodeIndex ) >
503500where
504501 K : Clone ,
@@ -544,7 +541,7 @@ where
544541 let prof_timer = tcx. dep_context ( ) . profiler ( ) . query_provider ( ) ;
545542
546543 // The dep-graph for this computation is already in-place.
547- let result = dep_graph. with_ignore ( || compute ( * tcx. dep_context ( ) , key. clone ( ) ) ) ;
544+ let result = dep_graph. with_ignore ( || query . compute ( * tcx. dep_context ( ) , key. clone ( ) ) ) ;
548545
549546 prof_timer. finish_with_query_invocation_id ( dep_node_index. into ( ) ) ;
550547
@@ -682,9 +679,9 @@ where
682679 Q :: Key : DepNodeParams < CTX :: DepContext > ,
683680 CTX : QueryContext ,
684681{
685- let query = & Q :: VTABLE ;
682+ let query = Q :: make_vtable ( tcx , & key ) ;
686683 let dep_node = if let QueryMode :: Ensure = mode {
687- let ( must_run, dep_node) = ensure_must_run ( tcx, & key, query) ;
684+ let ( must_run, dep_node) = ensure_must_run ( tcx, & key, & query) ;
688685 if !must_run {
689686 return None ;
690687 }
@@ -694,7 +691,6 @@ where
694691 } ;
695692
696693 debug ! ( "ty::query::get_query<{}>(key={:?}, span={:?})" , Q :: NAME , key, span) ;
697- let compute = Q :: compute_fn ( tcx, & key) ;
698694 let ( result, dep_node_index) = try_execute_query (
699695 tcx,
700696 Q :: query_state ( tcx) ,
@@ -703,8 +699,7 @@ where
703699 key,
704700 lookup,
705701 dep_node,
706- query,
707- compute,
702+ & query,
708703 ) ;
709704 if let Some ( dep_node_index) = dep_node_index {
710705 tcx. dep_context ( ) . dep_graph ( ) . read_index ( dep_node_index)
@@ -718,7 +713,6 @@ where
718713 Q :: Key : DepNodeParams < CTX :: DepContext > ,
719714 CTX : QueryContext ,
720715{
721- let query = & Q :: VTABLE ;
722716 debug_assert ! ( !Q :: ANON ) ;
723717
724718 // We may be concurrently trying both execute and force a query.
@@ -735,7 +729,7 @@ where
735729 Err ( lookup) => lookup,
736730 } ;
737731
738- let compute = Q :: compute_fn ( tcx, & key) ;
732+ let query = Q :: make_vtable ( tcx, & key) ;
739733 let state = Q :: query_state ( tcx) ;
740- try_execute_query ( tcx, state, cache, DUMMY_SP , key, lookup, Some ( dep_node) , query, compute ) ;
734+ try_execute_query ( tcx, state, cache, DUMMY_SP , key, lookup, Some ( dep_node) , & query) ;
741735}
0 commit comments