@@ -50,7 +50,9 @@ impl<'tcx> QueryCtxt<'tcx> {
5050 }
5151
5252 fn depth_limit_error ( self , job : QueryJobId ) {
53- let query_map = self . collect_active_jobs ( true ) . expect ( "failed to collect active queries" ) ;
53+ let query_map = self
54+ . collect_active_jobs_from_all_queries ( true )
55+ . expect ( "failed to collect active queries" ) ;
5456 let ( info, depth) = job. find_dep_kind_root ( query_map) ;
5557
5658 let suggested_limit = match self . tcx . recursion_limit ( ) {
@@ -98,7 +100,7 @@ impl<'tcx> QueryContext<'tcx> for QueryCtxt<'tcx> {
98100 tls:: with_related_context ( self . tcx , |icx| icx. query )
99101 }
100102
101- /// Returns a map of currently active query jobs.
103+ /// Returns a map of currently active query jobs, collected from all queries .
102104 ///
103105 /// If `require_complete` is `true`, this function locks all shards of the
104106 /// query results to produce a complete map, which always returns `Ok`.
@@ -108,12 +110,15 @@ impl<'tcx> QueryContext<'tcx> for QueryCtxt<'tcx> {
108110 /// Prefer passing `false` to `require_complete` to avoid potential deadlocks,
109111 /// especially when called from within a deadlock handler, unless a
110112 /// complete map is needed and no deadlock is possible at this call site.
111- fn collect_active_jobs ( self , require_complete : bool ) -> Result < QueryMap < ' tcx > , QueryMap < ' tcx > > {
113+ fn collect_active_jobs_from_all_queries (
114+ self ,
115+ require_complete : bool ,
116+ ) -> Result < QueryMap < ' tcx > , QueryMap < ' tcx > > {
112117 let mut jobs = QueryMap :: default ( ) ;
113118 let mut complete = true ;
114119
115- for collect in super :: COLLECT_ACTIVE_JOBS . iter ( ) {
116- if collect ( self . tcx , & mut jobs, require_complete) . is_none ( ) {
120+ for gather_fn in crate :: PER_QUERY_GATHER_ACTIVE_JOBS_FNS . iter ( ) {
121+ if gather_fn ( self . tcx , & mut jobs, require_complete) . is_none ( ) {
117122 complete = false ;
118123 }
119124 }
@@ -731,7 +736,10 @@ macro_rules! define_queries {
731736 }
732737 }
733738
734- pub ( crate ) fn collect_active_jobs<' tcx>(
739+ /// Internal per-query plumbing for collecting the set of active jobs for this query.
740+ ///
741+ /// Should only be called through `PER_QUERY_GATHER_ACTIVE_JOBS_FNS`.
742+ pub ( crate ) fn gather_active_jobs<' tcx>(
735743 tcx: TyCtxt <' tcx>,
736744 qmap: & mut QueryMap <' tcx>,
737745 require_complete: bool ,
@@ -741,12 +749,15 @@ macro_rules! define_queries {
741749 let name = stringify!( $name) ;
742750 $crate:: plumbing:: create_query_frame( tcx, rustc_middle:: query:: descs:: $name, key, kind, name)
743751 } ;
744- let res = tcx. query_system. states. $name. collect_active_jobs(
752+
753+ // Call `gather_active_jobs_inner` to do the actual work.
754+ let res = tcx. query_system. states. $name. gather_active_jobs_inner(
745755 tcx,
746756 make_frame,
747757 qmap,
748758 require_complete,
749759 ) ;
760+
750761 // this can be called during unwinding, and the function has a `try_`-prefix, so
751762 // don't `unwrap()` here, just manually check for `None` and do best-effort error
752763 // reporting.
@@ -816,10 +827,17 @@ macro_rules! define_queries {
816827
817828 // These arrays are used for iteration and can't be indexed by `DepKind`.
818829
819- const COLLECT_ACTIVE_JOBS : & [
820- for <' tcx> fn ( TyCtxt <' tcx>, & mut QueryMap <' tcx>, bool ) -> Option <( ) >
821- ] =
822- & [ $( 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) ,*
840+ ] ;
823841
824842 const ALLOC_SELF_PROFILE_QUERY_STRINGS : & [
825843 for <' tcx> fn ( TyCtxt <' tcx>, & mut QueryKeyStringCache )
0 commit comments