2
2
//! generate the actual methods on tcx which find and execute the provider,
3
3
//! manage the caches, and so forth.
4
4
5
- use crate :: dep_graph:: { DepContext , DepKind , DepNode } ;
5
+ use crate :: dep_graph:: { DepContext , DepKind , DepNode , DepNodeParams } ;
6
6
use crate :: dep_graph:: { DepNodeIndex , SerializedDepNodeIndex } ;
7
7
use crate :: query:: caches:: QueryCache ;
8
8
use crate :: query:: config:: { QueryDescription , QueryVtable , QueryVtableExt } ;
@@ -19,7 +19,7 @@ use rustc_data_structures::thin_vec::ThinVec;
19
19
#[ cfg( not( parallel_compiler) ) ]
20
20
use rustc_errors:: DiagnosticBuilder ;
21
21
use rustc_errors:: { Diagnostic , FatalError } ;
22
- use rustc_span:: Span ;
22
+ use rustc_span:: { Span , DUMMY_SP } ;
23
23
use std:: collections:: hash_map:: Entry ;
24
24
use std:: fmt:: Debug ;
25
25
use std:: hash:: { Hash , Hasher } ;
@@ -431,7 +431,7 @@ fn try_execute_query<CTX, C>(
431
431
) -> C :: Stored
432
432
where
433
433
C : QueryCache ,
434
- C :: Key : crate :: dep_graph :: DepNodeParams < CTX :: DepContext > ,
434
+ C :: Key : DepNodeParams < CTX :: DepContext > ,
435
435
CTX : QueryContext ,
436
436
{
437
437
let job = match JobOwner :: < ' _ , CTX :: DepKind , C > :: try_start (
@@ -693,7 +693,7 @@ fn get_query_impl<CTX, C>(
693
693
where
694
694
CTX : QueryContext ,
695
695
C : QueryCache ,
696
- C :: Key : crate :: dep_graph :: DepNodeParams < CTX :: DepContext > ,
696
+ C :: Key : DepNodeParams < CTX :: DepContext > ,
697
697
{
698
698
try_execute_query ( tcx, state, cache, span, key, lookup, query)
699
699
}
@@ -743,15 +743,25 @@ fn force_query_impl<CTX, C>(
743
743
tcx : CTX ,
744
744
state : & QueryState < CTX :: DepKind , C :: Key > ,
745
745
cache : & QueryCacheStore < C > ,
746
- key : C :: Key ,
747
- span : Span ,
748
746
dep_node : DepNode < CTX :: DepKind > ,
749
747
query : & QueryVtable < CTX , C :: Key , C :: Value > ,
750
- ) where
748
+ ) -> bool
749
+ where
751
750
C : QueryCache ,
752
- C :: Key : crate :: dep_graph :: DepNodeParams < CTX :: DepContext > ,
751
+ C :: Key : DepNodeParams < CTX :: DepContext > ,
753
752
CTX : QueryContext ,
754
753
{
754
+ debug_assert ! ( !query. anon) ;
755
+ debug_assert ! ( <C :: Key as DepNodeParams <CTX :: DepContext >>:: can_reconstruct_query_key( ) ) ;
756
+
757
+ let key = if let Some ( key) =
758
+ <C :: Key as DepNodeParams < CTX :: DepContext > >:: recover ( * tcx. dep_context ( ) , & dep_node)
759
+ {
760
+ key
761
+ } else {
762
+ return false ;
763
+ } ;
764
+
755
765
// We may be concurrently trying both execute and force a query.
756
766
// Ensure that only one of them runs the query.
757
767
let cached = cache. cache . lookup ( cache, & key, |_, index| {
@@ -765,25 +775,28 @@ fn force_query_impl<CTX, C>(
765
775
} ) ;
766
776
767
777
let lookup = match cached {
768
- Ok ( ( ) ) => return ,
778
+ Ok ( ( ) ) => return true ,
769
779
Err ( lookup) => lookup,
770
780
} ;
771
781
772
782
let job = match JobOwner :: < ' _ , CTX :: DepKind , C > :: try_start (
773
783
tcx,
774
784
state,
775
785
cache,
776
- span ,
786
+ DUMMY_SP ,
777
787
key. clone ( ) ,
778
788
lookup,
779
789
query,
780
790
) {
781
791
TryGetJob :: NotYetStarted ( job) => job,
782
- TryGetJob :: Cycle ( _) => return ,
792
+ TryGetJob :: Cycle ( _) => return true ,
783
793
#[ cfg( parallel_compiler) ]
784
- TryGetJob :: JobCompleted ( _) => return ,
794
+ TryGetJob :: JobCompleted ( _) => return true ,
785
795
} ;
796
+
786
797
force_query_with_job ( tcx, key, job, dep_node, query) ;
798
+
799
+ true
787
800
}
788
801
789
802
pub enum QueryMode {
@@ -800,7 +813,7 @@ pub fn get_query<Q, CTX>(
800
813
) -> Option < Q :: Stored >
801
814
where
802
815
Q : QueryDescription < CTX > ,
803
- Q :: Key : crate :: dep_graph :: DepNodeParams < CTX :: DepContext > ,
816
+ Q :: Key : DepNodeParams < CTX :: DepContext > ,
804
817
CTX : QueryContext ,
805
818
{
806
819
let query = & Q :: VTABLE ;
@@ -816,11 +829,19 @@ where
816
829
Some ( value)
817
830
}
818
831
819
- pub fn force_query < Q , CTX > ( tcx : CTX , key : Q :: Key , span : Span , dep_node : DepNode < CTX :: DepKind > )
832
+ pub fn force_query < Q , CTX > ( tcx : CTX , dep_node : & DepNode < CTX :: DepKind > ) -> bool
820
833
where
821
834
Q : QueryDescription < CTX > ,
822
- Q :: Key : crate :: dep_graph :: DepNodeParams < CTX :: DepContext > ,
835
+ Q :: Key : DepNodeParams < CTX :: DepContext > ,
823
836
CTX : QueryContext ,
824
837
{
825
- force_query_impl ( tcx, Q :: query_state ( tcx) , Q :: query_cache ( tcx) , key, span, dep_node, & Q :: VTABLE )
838
+ if Q :: ANON {
839
+ return false ;
840
+ }
841
+
842
+ if !<Q :: Key as DepNodeParams < CTX :: DepContext > >:: can_reconstruct_query_key ( ) {
843
+ return false ;
844
+ }
845
+
846
+ force_query_impl ( tcx, Q :: query_state ( tcx) , Q :: query_cache ( tcx) , * dep_node, & Q :: VTABLE )
826
847
}
0 commit comments