@@ -79,17 +79,20 @@ impl QueryContext for QueryCtxt<'_> {
7979 tls:: with_related_context ( self . tcx , |icx| icx. query )
8080 }
8181
82- /// Returns a query map representing active query jobs and a bool being false
83- /// if there was an error constructing the map.
84- fn collect_active_jobs ( self ) -> ( QueryMap , bool ) {
82+ /// Returns a query map representing active query jobs.
83+ /// It returns an incomplete map as an error if it fails
84+ /// to take locks.
85+ fn collect_active_jobs ( self ) -> Result < QueryMap , QueryMap > {
8586 let mut jobs = QueryMap :: default ( ) ;
8687 let mut complete = true ;
8788
8889 for collect in super :: TRY_COLLECT_ACTIVE_JOBS . iter ( ) {
89- collect ( self . tcx , & mut jobs, & mut complete) ;
90+ if collect ( self . tcx , & mut jobs) . is_none ( ) {
91+ complete = false ;
92+ }
9093 }
9194
92- ( jobs, complete )
95+ if complete { Ok ( jobs) } else { Err ( jobs ) }
9396 }
9497
9598 // Interactions with on_disk_cache
@@ -143,7 +146,11 @@ impl QueryContext for QueryCtxt<'_> {
143146
144147 fn depth_limit_error ( self , job : QueryJobId ) {
145148 // FIXME: `collect_active_jobs` expects no locks to be held, which doesn't hold for this call.
146- let ( info, depth) = job. find_dep_kind_root ( self . collect_active_jobs ( ) . 0 ) ;
149+ let query_map = match self . collect_active_jobs ( ) {
150+ Ok ( query_map) => query_map,
151+ Err ( query_map) => query_map,
152+ } ;
153+ let ( info, depth) = job. find_dep_kind_root ( query_map) ;
147154
148155 let suggested_limit = match self . recursion_limit ( ) {
149156 Limit ( 0 ) => Limit ( 2 ) ,
@@ -681,7 +688,7 @@ macro_rules! define_queries {
681688 }
682689 }
683690
684- pub ( crate ) fn try_collect_active_jobs<' tcx>( tcx: TyCtxt <' tcx>, qmap: & mut QueryMap , complete : & mut bool ) {
691+ pub ( crate ) fn try_collect_active_jobs<' tcx>( tcx: TyCtxt <' tcx>, qmap: & mut QueryMap ) -> Option < ( ) > {
685692 let make_query = |tcx, key| {
686693 let kind = rustc_middle:: dep_graph:: dep_kinds:: $name;
687694 let name = stringify!( $name) ;
@@ -696,12 +703,12 @@ macro_rules! define_queries {
696703 // don't `unwrap()` here, just manually check for `None` and do best-effort error
697704 // reporting.
698705 if res. is_none( ) {
699- * complete = false ;
700706 tracing:: warn!(
701707 "Failed to collect active jobs for query with name `{}`!" ,
702708 stringify!( $name)
703709 ) ;
704710 }
711+ res
705712 }
706713
707714 pub ( crate ) fn alloc_self_profile_query_strings<' tcx>(
@@ -761,7 +768,7 @@ macro_rules! define_queries {
761768
762769 // These arrays are used for iteration and can't be indexed by `DepKind`.
763770
764- const TRY_COLLECT_ACTIVE_JOBS : & [ for <' tcx> fn ( TyCtxt <' tcx>, & mut QueryMap , & mut bool ) ] =
771+ const TRY_COLLECT_ACTIVE_JOBS : & [ for <' tcx> fn ( TyCtxt <' tcx>, & mut QueryMap ) -> Option < ( ) > ] =
765772 & [ $( query_impl:: $name:: try_collect_active_jobs) ,* ] ;
766773
767774 const ALLOC_SELF_PROFILE_QUERY_STRINGS : & [
0 commit comments