Skip to content

Commit 7851d98

Browse files
Rollup merge of #118374 - klensy:collect_active_jobs, r=compiler-errors
QueryContext: rename try_collect_active_jobs -> collect_active_jobs, change return type from Option<QueryMap> to QueryMap As there currently always Some(...) inside.
2 parents 4936b3a + 31d9983 commit 7851d98

File tree

5 files changed

+14
-20
lines changed

5 files changed

+14
-20
lines changed

compiler/rustc_interface/src/util.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,8 @@ pub(crate) fn run_in_thread_pool_with_globals<F: FnOnce() -> R + Send, R: Send>(
126126
.deadlock_handler(|| {
127127
// On deadlock, creates a new thread and forwards information in thread
128128
// locals to it. The new thread runs the deadlock handler.
129-
let query_map = FromDyn::from(tls::with(|tcx| {
130-
QueryCtxt::new(tcx)
131-
.try_collect_active_jobs()
132-
.expect("active jobs shouldn't be locked in deadlock handler")
133-
}));
129+
let query_map =
130+
FromDyn::from(tls::with(|tcx| QueryCtxt::new(tcx).collect_active_jobs()));
134131
let registry = rayon_core::Registry::current();
135132
thread::spawn(move || deadlock(query_map.into_inner(), &registry));
136133
});

compiler/rustc_query_impl/src/plumbing.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,14 @@ impl QueryContext for QueryCtxt<'_> {
8080
tls::with_related_context(self.tcx, |icx| icx.query)
8181
}
8282

83-
fn try_collect_active_jobs(self) -> Option<QueryMap> {
83+
fn collect_active_jobs(self) -> QueryMap {
8484
let mut jobs = QueryMap::default();
8585

8686
for collect in super::TRY_COLLECT_ACTIVE_JOBS.iter() {
8787
collect(self.tcx, &mut jobs);
8888
}
8989

90-
Some(jobs)
90+
jobs
9191
}
9292

9393
// Interactions with on_disk_cache
@@ -155,11 +155,11 @@ impl QueryContext for QueryCtxt<'_> {
155155
fn depth_limit_error(self, job: QueryJobId) {
156156
let mut span = None;
157157
let mut layout_of_depth = None;
158-
if let Some(map) = self.try_collect_active_jobs() {
159-
if let Some((info, depth)) = job.try_find_layout_root(map, dep_kinds::layout_of) {
160-
span = Some(info.job.span);
161-
layout_of_depth = Some(LayoutOfDepth { desc: info.query.description, depth });
162-
}
158+
if let Some((info, depth)) =
159+
job.try_find_layout_root(self.collect_active_jobs(), dep_kinds::layout_of)
160+
{
161+
span = Some(info.job.span);
162+
layout_of_depth = Some(LayoutOfDepth { desc: info.query.description, depth });
163163
}
164164

165165
let suggested_limit = match self.recursion_limit() {

compiler/rustc_query_system/src/query/job.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -620,13 +620,13 @@ pub fn print_query_stack<Qcx: QueryContext>(
620620
// state if it was responsible for triggering the panic.
621621
let mut count_printed = 0;
622622
let mut count_total = 0;
623-
let query_map = qcx.try_collect_active_jobs();
623+
let query_map = qcx.collect_active_jobs();
624624

625625
if let Some(ref mut file) = file {
626626
let _ = writeln!(file, "\n\nquery stack during panic:");
627627
}
628628
while let Some(query) = current_query {
629-
let Some(query_info) = query_map.as_ref().and_then(|map| map.get(&query)) else {
629+
let Some(query_info) = query_map.get(&query) else {
630630
break;
631631
};
632632
if Some(count_printed) < num_frames || num_frames.is_none() {

compiler/rustc_query_system/src/query/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ pub trait QueryContext: HasDepContext {
106106
/// Get the query information from the TLS context.
107107
fn current_query_job(self) -> Option<QueryJobId>;
108108

109-
fn try_collect_active_jobs(self) -> Option<QueryMap>;
109+
fn collect_active_jobs(self) -> QueryMap;
110110

111111
/// Load side effects associated to the node in the previous session.
112112
fn load_side_effects(self, prev_dep_node_index: SerializedDepNodeIndex) -> QuerySideEffects;

compiler/rustc_query_system/src/query/plumbing.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -242,11 +242,8 @@ where
242242
Q: QueryConfig<Qcx>,
243243
Qcx: QueryContext,
244244
{
245-
let error = try_execute.find_cycle_in_stack(
246-
qcx.try_collect_active_jobs().unwrap(),
247-
&qcx.current_query_job(),
248-
span,
249-
);
245+
let error =
246+
try_execute.find_cycle_in_stack(qcx.collect_active_jobs(), &qcx.current_query_job(), span);
250247
(mk_cycle(query, qcx, error), None)
251248
}
252249

0 commit comments

Comments
 (0)