22//! generate the actual methods on tcx which find and execute the provider,
33//! manage the caches, and so forth.
44
5- use crate :: dep_graph:: { DepContext , DepKind , DepNode } ;
5+ use crate :: dep_graph:: { DepContext , DepKind , DepNode , DepNodeParams } ;
66use crate :: dep_graph:: { DepNodeIndex , SerializedDepNodeIndex } ;
77use crate :: query:: caches:: QueryCache ;
88use crate :: query:: config:: { QueryDescription , QueryVtable , QueryVtableExt } ;
@@ -19,7 +19,7 @@ use rustc_data_structures::thin_vec::ThinVec;
1919#[ cfg( not( parallel_compiler) ) ]
2020use rustc_errors:: DiagnosticBuilder ;
2121use rustc_errors:: { Diagnostic , FatalError } ;
22- use rustc_span:: Span ;
22+ use rustc_span:: { Span , DUMMY_SP } ;
2323use std:: collections:: hash_map:: Entry ;
2424use std:: fmt:: Debug ;
2525use std:: hash:: { Hash , Hasher } ;
@@ -431,7 +431,7 @@ fn try_execute_query<CTX, C>(
431431) -> C :: Stored
432432where
433433 C : QueryCache ,
434- C :: Key : crate :: dep_graph :: DepNodeParams < CTX :: DepContext > ,
434+ C :: Key : DepNodeParams < CTX :: DepContext > ,
435435 CTX : QueryContext ,
436436{
437437 let job = match JobOwner :: < ' _ , CTX :: DepKind , C > :: try_start (
@@ -693,7 +693,7 @@ fn get_query_impl<CTX, C>(
693693where
694694 CTX : QueryContext ,
695695 C : QueryCache ,
696- C :: Key : crate :: dep_graph :: DepNodeParams < CTX :: DepContext > ,
696+ C :: Key : DepNodeParams < CTX :: DepContext > ,
697697{
698698 try_execute_query ( tcx, state, cache, span, key, lookup, query)
699699}
@@ -743,15 +743,25 @@ fn force_query_impl<CTX, C>(
743743 tcx : CTX ,
744744 state : & QueryState < CTX :: DepKind , C :: Key > ,
745745 cache : & QueryCacheStore < C > ,
746- key : C :: Key ,
747- span : Span ,
748746 dep_node : DepNode < CTX :: DepKind > ,
749747 query : & QueryVtable < CTX , C :: Key , C :: Value > ,
750- ) where
748+ ) -> bool
749+ where
751750 C : QueryCache ,
752- C :: Key : crate :: dep_graph :: DepNodeParams < CTX :: DepContext > ,
751+ C :: Key : DepNodeParams < CTX :: DepContext > ,
753752 CTX : QueryContext ,
754753{
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+
755765 // We may be concurrently trying both execute and force a query.
756766 // Ensure that only one of them runs the query.
757767 let cached = cache. cache . lookup ( cache, & key, |_, index| {
@@ -765,25 +775,28 @@ fn force_query_impl<CTX, C>(
765775 } ) ;
766776
767777 let lookup = match cached {
768- Ok ( ( ) ) => return ,
778+ Ok ( ( ) ) => return true ,
769779 Err ( lookup) => lookup,
770780 } ;
771781
772782 let job = match JobOwner :: < ' _ , CTX :: DepKind , C > :: try_start (
773783 tcx,
774784 state,
775785 cache,
776- span ,
786+ DUMMY_SP ,
777787 key. clone ( ) ,
778788 lookup,
779789 query,
780790 ) {
781791 TryGetJob :: NotYetStarted ( job) => job,
782- TryGetJob :: Cycle ( _) => return ,
792+ TryGetJob :: Cycle ( _) => return true ,
783793 #[ cfg( parallel_compiler) ]
784- TryGetJob :: JobCompleted ( _) => return ,
794+ TryGetJob :: JobCompleted ( _) => return true ,
785795 } ;
796+
786797 force_query_with_job ( tcx, key, job, dep_node, query) ;
798+
799+ true
787800}
788801
789802pub enum QueryMode {
@@ -800,7 +813,7 @@ pub fn get_query<Q, CTX>(
800813) -> Option < Q :: Stored >
801814where
802815 Q : QueryDescription < CTX > ,
803- Q :: Key : crate :: dep_graph :: DepNodeParams < CTX :: DepContext > ,
816+ Q :: Key : DepNodeParams < CTX :: DepContext > ,
804817 CTX : QueryContext ,
805818{
806819 let query = & Q :: VTABLE ;
@@ -816,11 +829,19 @@ where
816829 Some ( value)
817830}
818831
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
820833where
821834 Q : QueryDescription < CTX > ,
822- Q :: Key : crate :: dep_graph :: DepNodeParams < CTX :: DepContext > ,
835+ Q :: Key : DepNodeParams < CTX :: DepContext > ,
823836 CTX : QueryContext ,
824837{
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 )
826847}
0 commit comments