@@ -81,7 +81,7 @@ impl<'tcx> QueryContext<'tcx> for QueryCtxt<'tcx> {
8181 tls:: with_related_context ( self . tcx , |icx| icx. query )
8282 }
8383
84- /// Returns a map of currently active query jobs.
84+ /// Returns a map of currently active query jobs, collected from all queries .
8585 ///
8686 /// If `require_complete` is `true`, this function locks all shards of the
8787 /// query results to produce a complete map, which always returns `Ok`.
@@ -91,12 +91,15 @@ impl<'tcx> QueryContext<'tcx> for QueryCtxt<'tcx> {
9191 /// Prefer passing `false` to `require_complete` to avoid potential deadlocks,
9292 /// especially when called from within a deadlock handler, unless a
9393 /// complete map is needed and no deadlock is possible at this call site.
94- fn collect_active_jobs ( self , require_complete : bool ) -> Result < QueryMap < ' tcx > , QueryMap < ' tcx > > {
94+ fn collect_active_jobs_from_all_queries (
95+ self ,
96+ require_complete : bool ,
97+ ) -> Result < QueryMap < ' tcx > , QueryMap < ' tcx > > {
9598 let mut jobs = QueryMap :: default ( ) ;
9699 let mut complete = true ;
97100
98- for collect in super :: COLLECT_ACTIVE_JOBS . iter ( ) {
99- if collect ( self . tcx , & mut jobs, require_complete) . is_none ( ) {
101+ for gather_fn in crate :: PER_QUERY_GATHER_ACTIVE_JOBS_FNS . iter ( ) {
102+ if gather_fn ( self . tcx , & mut jobs, require_complete) . is_none ( ) {
100103 complete = false ;
101104 }
102105 }
@@ -164,7 +167,9 @@ impl<'tcx> QueryContext<'tcx> for QueryCtxt<'tcx> {
164167 }
165168
166169 fn depth_limit_error ( self , job : QueryJobId ) {
167- let query_map = self . collect_active_jobs ( true ) . expect ( "failed to collect active queries" ) ;
170+ let query_map = self
171+ . collect_active_jobs_from_all_queries ( true )
172+ . expect ( "failed to collect active queries" ) ;
168173 let ( info, depth) = job. find_dep_kind_root ( query_map) ;
169174
170175 let suggested_limit = match self . tcx . recursion_limit ( ) {
@@ -733,7 +738,10 @@ macro_rules! define_queries {
733738 }
734739 }
735740
736- pub ( crate ) fn collect_active_jobs<' tcx>(
741+ /// Internal per-query plumbing for collecting the set of active jobs for this query.
742+ ///
743+ /// Should only be called through `PER_QUERY_GATHER_ACTIVE_JOBS_FNS`.
744+ pub ( crate ) fn gather_active_jobs_outer<' tcx>(
737745 tcx: TyCtxt <' tcx>,
738746 qmap: & mut QueryMap <' tcx>,
739747 require_complete: bool ,
@@ -743,7 +751,8 @@ macro_rules! define_queries {
743751 let name = stringify!( $name) ;
744752 $crate:: plumbing:: create_query_frame( tcx, rustc_middle:: query:: descs:: $name, key, kind, name)
745753 } ;
746- let res = tcx. query_system. states. $name. collect_active_jobs(
754+ // We can call `gather_active_jobs_inner` here.
755+ let res = tcx. query_system. states. $name. gather_active_jobs_inner(
747756 tcx,
748757 make_query,
749758 qmap,
@@ -818,10 +827,17 @@ macro_rules! define_queries {
818827
819828 // These arrays are used for iteration and can't be indexed by `DepKind`.
820829
821- const COLLECT_ACTIVE_JOBS : & [
822- for <' tcx> fn ( TyCtxt <' tcx>, & mut QueryMap <' tcx>, bool ) -> Option <( ) >
823- ] =
824- & [ $( query_impl:: $name:: collect_active_jobs) ,* ] ;
830+ /// Used by `collect_active_jobs_from_all_queries` to iterate over all
831+ /// queries, and gather the active jobs for each query.
832+ ///
833+ /// (We arbitrarily use the word "gather" when collecting the jobs for
834+ /// each individual query, so that we have distinct function names to
835+ /// grep for.)
836+ const PER_QUERY_GATHER_ACTIVE_JOBS_FNS : & [
837+ for <' tcx> fn ( TyCtxt <' tcx>, & mut QueryMap <' tcx>, require_complete: bool ) -> Option <( ) >
838+ ] = & [
839+ $( query_impl:: $name:: gather_active_jobs_outer) ,*
840+ ] ;
825841
826842 const ALLOC_SELF_PROFILE_QUERY_STRINGS : & [
827843 for <' tcx> fn ( TyCtxt <' tcx>, & mut QueryKeyStringCache )
0 commit comments