@@ -79,17 +79,20 @@ impl QueryContext for QueryCtxt<'_> {
79
79
tls:: with_related_context ( self . tcx , |icx| icx. query )
80
80
}
81
81
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 > {
85
86
let mut jobs = QueryMap :: default ( ) ;
86
87
let mut complete = true ;
87
88
88
89
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
+ }
90
93
}
91
94
92
- ( jobs, complete )
95
+ if complete { Ok ( jobs) } else { Err ( jobs ) }
93
96
}
94
97
95
98
// Interactions with on_disk_cache
@@ -143,7 +146,11 @@ impl QueryContext for QueryCtxt<'_> {
143
146
144
147
fn depth_limit_error ( self , job : QueryJobId ) {
145
148
// 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) ;
147
154
148
155
let suggested_limit = match self . recursion_limit ( ) {
149
156
Limit ( 0 ) => Limit ( 2 ) ,
@@ -681,7 +688,7 @@ macro_rules! define_queries {
681
688
}
682
689
}
683
690
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 < ( ) > {
685
692
let make_query = |tcx, key| {
686
693
let kind = rustc_middle:: dep_graph:: dep_kinds:: $name;
687
694
let name = stringify!( $name) ;
@@ -696,12 +703,12 @@ macro_rules! define_queries {
696
703
// don't `unwrap()` here, just manually check for `None` and do best-effort error
697
704
// reporting.
698
705
if res. is_none( ) {
699
- * complete = false ;
700
706
tracing:: warn!(
701
707
"Failed to collect active jobs for query with name `{}`!" ,
702
708
stringify!( $name)
703
709
) ;
704
710
}
711
+ res
705
712
}
706
713
707
714
pub ( crate ) fn alloc_self_profile_query_strings<' tcx>(
@@ -761,7 +768,7 @@ macro_rules! define_queries {
761
768
762
769
// These arrays are used for iteration and can't be indexed by `DepKind`.
763
770
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 < ( ) > ] =
765
772
& [ $( query_impl:: $name:: try_collect_active_jobs) ,* ] ;
766
773
767
774
const ALLOC_SELF_PROFILE_QUERY_STRINGS : & [
0 commit comments