@@ -382,7 +382,6 @@ fn try_execute_query<CTX, C>(
382
382
lookup : QueryLookup ,
383
383
dep_node : Option < DepNode < CTX :: DepKind > > ,
384
384
query : & QueryVtable < CTX , C :: Key , C :: Value > ,
385
- compute : fn ( CTX :: DepContext , C :: Key ) -> C :: Value ,
386
385
) -> ( C :: Stored , Option < DepNodeIndex > )
387
386
where
388
387
C : QueryCache ,
@@ -398,7 +397,7 @@ where
398
397
query. dep_kind ,
399
398
) {
400
399
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 ) ;
402
401
let result = job. complete ( cache, result, dep_node_index) ;
403
402
( result, Some ( dep_node_index) )
404
403
}
@@ -429,7 +428,6 @@ fn execute_job<CTX, K, V>(
429
428
mut dep_node_opt : Option < DepNode < CTX :: DepKind > > ,
430
429
query : & QueryVtable < CTX , K , V > ,
431
430
job_id : QueryJobId < CTX :: DepKind > ,
432
- compute : fn ( CTX :: DepContext , K ) -> V ,
433
431
) -> ( V , DepNodeIndex )
434
432
where
435
433
K : Clone + DepNodeParams < CTX :: DepContext > ,
@@ -441,7 +439,7 @@ where
441
439
// Fast path for when incr. comp. is off.
442
440
if !dep_graph. is_fully_enabled ( ) {
443
441
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) ) ;
445
443
let dep_node_index = dep_graph. next_virtual_depnode_index ( ) ;
446
444
prof_timer. finish_with_query_invocation_id ( dep_node_index. into ( ) ) ;
447
445
return ( result, dep_node_index) ;
@@ -455,7 +453,7 @@ where
455
453
// The diagnostics for this query will be promoted to the current session during
456
454
// `try_mark_green()`, so we can ignore them here.
457
455
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)
459
457
} ) {
460
458
return ret;
461
459
}
@@ -467,14 +465,14 @@ where
467
465
let ( result, dep_node_index) = tcx. start_query ( job_id, Some ( & diagnostics) , || {
468
466
if query. anon {
469
467
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)
471
469
} ) ;
472
470
}
473
471
474
472
// `to_dep_node` is expensive for some `DepKind`s.
475
473
let dep_node = dep_node_opt. unwrap_or_else ( || query. to_dep_node ( * tcx. dep_context ( ) , & key) ) ;
476
474
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 )
478
476
} ) ;
479
477
480
478
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>(
498
496
key : & K ,
499
497
dep_node : & DepNode < CTX :: DepKind > ,
500
498
query : & QueryVtable < CTX , K , V > ,
501
- compute : fn ( CTX :: DepContext , K ) -> V ,
502
499
) -> Option < ( V , DepNodeIndex ) >
503
500
where
504
501
K : Clone ,
@@ -544,7 +541,7 @@ where
544
541
let prof_timer = tcx. dep_context ( ) . profiler ( ) . query_provider ( ) ;
545
542
546
543
// 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 ( ) ) ) ;
548
545
549
546
prof_timer. finish_with_query_invocation_id ( dep_node_index. into ( ) ) ;
550
547
@@ -682,9 +679,9 @@ where
682
679
Q :: Key : DepNodeParams < CTX :: DepContext > ,
683
680
CTX : QueryContext ,
684
681
{
685
- let query = & Q :: VTABLE ;
682
+ let query = Q :: make_vtable ( tcx , & key ) ;
686
683
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) ;
688
685
if !must_run {
689
686
return None ;
690
687
}
@@ -694,7 +691,6 @@ where
694
691
} ;
695
692
696
693
debug ! ( "ty::query::get_query<{}>(key={:?}, span={:?})" , Q :: NAME , key, span) ;
697
- let compute = Q :: compute_fn ( tcx, & key) ;
698
694
let ( result, dep_node_index) = try_execute_query (
699
695
tcx,
700
696
Q :: query_state ( tcx) ,
@@ -703,8 +699,7 @@ where
703
699
key,
704
700
lookup,
705
701
dep_node,
706
- query,
707
- compute,
702
+ & query,
708
703
) ;
709
704
if let Some ( dep_node_index) = dep_node_index {
710
705
tcx. dep_context ( ) . dep_graph ( ) . read_index ( dep_node_index)
@@ -718,7 +713,6 @@ where
718
713
Q :: Key : DepNodeParams < CTX :: DepContext > ,
719
714
CTX : QueryContext ,
720
715
{
721
- let query = & Q :: VTABLE ;
722
716
debug_assert ! ( !Q :: ANON ) ;
723
717
724
718
// We may be concurrently trying both execute and force a query.
@@ -735,7 +729,7 @@ where
735
729
Err ( lookup) => lookup,
736
730
} ;
737
731
738
- let compute = Q :: compute_fn ( tcx, & key) ;
732
+ let query = Q :: make_vtable ( tcx, & key) ;
739
733
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) ;
741
735
}
0 commit comments