@@ -312,7 +312,7 @@ where
312312}
313313
314314#[ inline( never) ]
315- fn try_execute_query < Q , Qcx > (
315+ fn try_execute_query < Q , Qcx , const INCR : bool > (
316316 query : Q ,
317317 qcx : Qcx ,
318318 span : Span ,
@@ -355,7 +355,7 @@ where
355355 // Drop the lock before we start executing the query
356356 drop ( state_lock) ;
357357
358- execute_job ( query, qcx, state, key, id, dep_node)
358+ execute_job :: < _ , _ , INCR > ( query, qcx, state, key, id, dep_node)
359359 }
360360 Entry :: Occupied ( mut entry) => {
361361 match entry. get_mut ( ) {
@@ -383,7 +383,7 @@ where
383383}
384384
385385#[ inline( always) ]
386- fn execute_job < Q , Qcx > (
386+ fn execute_job < Q , Qcx , const INCR : bool > (
387387 query : Q ,
388388 qcx : Qcx ,
389389 state : & QueryState < Q :: Key , Qcx :: DepKind > ,
@@ -398,9 +398,19 @@ where
398398 // Use `JobOwner` so the query will be poisoned if executing it panics.
399399 let job_owner = JobOwner { state, key } ;
400400
401- let ( result, dep_node_index) = match qcx. dep_context ( ) . dep_graph ( ) . data ( ) {
402- None => execute_job_non_incr ( query, qcx, key, id) ,
403- Some ( data) => execute_job_incr ( query, qcx, data, key, dep_node, id) ,
401+ debug_assert_eq ! ( qcx. dep_context( ) . dep_graph( ) . is_fully_enabled( ) , INCR ) ;
402+
403+ let ( result, dep_node_index) = if INCR {
404+ execute_job_incr (
405+ query,
406+ qcx,
407+ qcx. dep_context ( ) . dep_graph ( ) . data ( ) . unwrap ( ) ,
408+ key,
409+ dep_node,
410+ id,
411+ )
412+ } else {
413+ execute_job_non_incr ( query, qcx, key, id)
404414 } ;
405415
406416 let cache = query. query_cache ( qcx) ;
@@ -784,7 +794,18 @@ pub enum QueryMode {
784794}
785795
786796#[ inline( always) ]
787- pub fn get_query < Q , Qcx > (
797+ pub fn get_query_non_incr < Q , Qcx > ( query : Q , qcx : Qcx , span : Span , key : Q :: Key ) -> Q :: Value
798+ where
799+ Q : QueryConfig < Qcx > ,
800+ Qcx : QueryContext ,
801+ {
802+ debug_assert ! ( !qcx. dep_context( ) . dep_graph( ) . is_fully_enabled( ) ) ;
803+
804+ ensure_sufficient_stack ( || try_execute_query :: < Q , Qcx , false > ( query, qcx, span, key, None ) . 0 )
805+ }
806+
807+ #[ inline( always) ]
808+ pub fn get_query_incr < Q , Qcx > (
788809 query : Q ,
789810 qcx : Qcx ,
790811 span : Span ,
@@ -795,6 +816,8 @@ where
795816 Q : QueryConfig < Qcx > ,
796817 Qcx : QueryContext ,
797818{
819+ debug_assert ! ( qcx. dep_context( ) . dep_graph( ) . is_fully_enabled( ) ) ;
820+
798821 let dep_node = if let QueryMode :: Ensure { check_cache } = mode {
799822 let ( must_run, dep_node) = ensure_must_run ( query, qcx, & key, check_cache) ;
800823 if !must_run {
@@ -805,8 +828,9 @@ where
805828 None
806829 } ;
807830
808- let ( result, dep_node_index) =
809- ensure_sufficient_stack ( || try_execute_query ( query, qcx, span, key, dep_node) ) ;
831+ let ( result, dep_node_index) = ensure_sufficient_stack ( || {
832+ try_execute_query :: < _ , _ , true > ( query, qcx, span, key, dep_node)
833+ } ) ;
810834 if let Some ( dep_node_index) = dep_node_index {
811835 qcx. dep_context ( ) . dep_graph ( ) . read_index ( dep_node_index)
812836 }
@@ -831,5 +855,7 @@ pub fn force_query<Q, Qcx>(
831855
832856 debug_assert ! ( !query. anon( ) ) ;
833857
834- ensure_sufficient_stack ( || try_execute_query ( query, qcx, DUMMY_SP , key, Some ( dep_node) ) ) ;
858+ ensure_sufficient_stack ( || {
859+ try_execute_query :: < _ , _ , true > ( query, qcx, DUMMY_SP , key, Some ( dep_node) )
860+ } ) ;
835861}
0 commit comments