@@ -29,9 +29,10 @@ use rustc_middle::ty::{self, TyCtxt};
2929use rustc_serialize:: { Decodable , Encodable } ;
3030use rustc_span:: def_id:: LOCAL_CRATE ;
3131
32+ use crate :: collect_active_jobs_from_all_queries;
3233use crate :: error:: { QueryOverflow , QueryOverflowNote } ;
3334use crate :: execution:: { all_inactive, force_query} ;
34- use crate :: job:: { QueryJobMap , find_dep_kind_root} ;
35+ use crate :: job:: find_dep_kind_root;
3536
3637fn depth_limit_error < ' tcx > ( tcx : TyCtxt < ' tcx > , job : QueryJobId ) {
3738 let job_map =
@@ -94,32 +95,6 @@ pub(crate) fn start_query<'tcx, R>(
9495 } )
9596}
9697
97- /// Returns a map of currently active query jobs, collected from all queries.
98- ///
99- /// If `require_complete` is `true`, this function locks all shards of the
100- /// query results to produce a complete map, which always returns `Ok`.
101- /// Otherwise, it may return an incomplete map as an error if any shard
102- /// lock cannot be acquired.
103- ///
104- /// Prefer passing `false` to `require_complete` to avoid potential deadlocks,
105- /// especially when called from within a deadlock handler, unless a
106- /// complete map is needed and no deadlock is possible at this call site.
107- pub fn collect_active_jobs_from_all_queries < ' tcx > (
108- tcx : TyCtxt < ' tcx > ,
109- require_complete : bool ,
110- ) -> Result < QueryJobMap < ' tcx > , QueryJobMap < ' tcx > > {
111- let mut job_map_out = QueryJobMap :: default ( ) ;
112- let mut complete = true ;
113-
114- for gather_fn in crate :: PER_QUERY_GATHER_ACTIVE_JOBS_FNS . iter ( ) {
115- if gather_fn ( tcx, require_complete, & mut job_map_out) . is_none ( ) {
116- complete = false ;
117- }
118- }
119-
120- if complete { Ok ( job_map_out) } else { Err ( job_map_out) }
121- }
122-
12398pub ( super ) fn try_mark_green < ' tcx > ( tcx : TyCtxt < ' tcx > , dep_node : & DepNode ) -> bool {
12499 tcx. dep_graph . try_mark_green ( tcx, dep_node) . is_some ( )
125100}
@@ -618,22 +593,6 @@ macro_rules! define_queries {
618593 }
619594 }
620595
621- /// Internal per-query plumbing for collecting the set of active jobs for this query.
622- ///
623- /// Should only be called through `PER_QUERY_GATHER_ACTIVE_JOBS_FNS`.
624- pub ( crate ) fn gather_active_jobs<' tcx>(
625- tcx: TyCtxt <' tcx>,
626- require_complete: bool ,
627- job_map_out: & mut QueryJobMap <' tcx>,
628- ) -> Option <( ) > {
629- crate :: execution:: gather_active_jobs_inner(
630- & tcx. query_system. query_vtables. $name,
631- tcx,
632- require_complete,
633- job_map_out,
634- )
635- }
636-
637596 pub ( crate ) fn alloc_self_profile_query_strings<' tcx>(
638597 tcx: TyCtxt <' tcx>,
639598 string_cache: & mut QueryKeyStringCache
@@ -672,21 +631,37 @@ macro_rules! define_queries {
672631
673632 // These arrays are used for iteration and can't be indexed by `DepKind`.
674633
675- /// Used by `collect_active_jobs_from_all_queries` to iterate over all
676- /// queries, and gather the active jobs for each query.
634+ /// Returns a map of currently active query jobs, collected from all queries.
677635 ///
678- /// (We arbitrarily use the word "gather" when collecting the jobs for
679- /// each individual query, so that we have distinct function names to
680- /// grep for.)
681- const PER_QUERY_GATHER_ACTIVE_JOBS_FNS : & [
682- for <' tcx> fn (
683- tcx: TyCtxt <' tcx>,
684- require_complete: bool ,
685- job_map_out: & mut QueryJobMap <' tcx>,
686- ) -> Option <( ) >
687- ] = & [
688- $( $crate:: query_impl:: $name:: gather_active_jobs ) ,*
689- ] ;
636+ /// If `require_complete` is `true`, this function locks all shards of the
637+ /// query results to produce a complete map, which always returns `Ok`.
638+ /// Otherwise, it may return an incomplete map as an error if any shard
639+ /// lock cannot be acquired.
640+ ///
641+ /// Prefer passing `false` to `require_complete` to avoid potential deadlocks,
642+ /// especially when called from within a deadlock handler, unless a
643+ /// complete map is needed and no deadlock is possible at this call site.
644+ pub fn collect_active_jobs_from_all_queries<' tcx>(
645+ tcx: TyCtxt <' tcx>,
646+ require_complete: bool ,
647+ ) -> Result <QueryJobMap <' tcx>, QueryJobMap <' tcx>> {
648+ let mut job_map_out = QueryJobMap :: default ( ) ;
649+ let mut complete = true ;
650+
651+ $(
652+ let res = crate :: execution:: gather_active_jobs(
653+ & tcx. query_system. query_vtables. $name,
654+ tcx,
655+ require_complete,
656+ & mut job_map_out,
657+ ) ;
658+ if res. is_none( ) {
659+ complete = false ;
660+ }
661+ ) *
662+
663+ if complete { Ok ( job_map_out) } else { Err ( job_map_out) }
664+ }
690665
691666 const ALLOC_SELF_PROFILE_QUERY_STRINGS : & [
692667 for <' tcx> fn ( TyCtxt <' tcx>, & mut QueryKeyStringCache )
0 commit comments