Skip to content

Commit d35179f

Browse files
committed
Don't use wait_for_query without the Rayon thread pool
1 parent 5739349 commit d35179f

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

compiler/rustc_query_system/src/query/job.rs

-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ impl<D: DepKind> QueryJob<D> {
124124
}
125125

126126
impl QueryJobId {
127-
#[cfg(not(parallel_compiler))]
128127
pub(super) fn find_cycle_in_stack<D: DepKind>(
129128
&self,
130129
query_map: QueryMap<D>,

compiler/rustc_query_system/src/query/plumbing.rs

+13-12
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ use crate::query::job::{report_cycle, QueryInfo, QueryJob, QueryJobId, QueryJobI
1212
use crate::query::SerializedDepNodeIndex;
1313
use crate::query::{QueryContext, QueryMap, QuerySideEffects, QueryStackFrame};
1414
use crate::HandleCycleError;
15-
#[cfg(parallel_compiler)]
16-
use rustc_data_structures::cold_path;
1715
use rustc_data_structures::fingerprint::Fingerprint;
1816
use rustc_data_structures::fx::FxHashMap;
1917
use rustc_data_structures::sharded::Sharded;
2018
use rustc_data_structures::stack::ensure_sufficient_stack;
2119
use rustc_data_structures::sync::Lock;
20+
#[cfg(parallel_compiler)]
21+
use rustc_data_structures::{cold_path, sync};
2222
use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed, FatalError};
2323
use rustc_span::{Span, DUMMY_SP};
2424
use std::cell::Cell;
@@ -223,7 +223,6 @@ where
223223

224224
#[cold]
225225
#[inline(never)]
226-
#[cfg(not(parallel_compiler))]
227226
fn cycle_error<Q, Qcx>(
228227
query: Q,
229228
qcx: Qcx,
@@ -336,23 +335,25 @@ where
336335
}
337336
Entry::Occupied(mut entry) => {
338337
match entry.get_mut() {
339-
#[cfg(not(parallel_compiler))]
340338
QueryResult::Started(job) => {
339+
#[cfg(parallel_compiler)]
340+
if sync::is_dyn_thread_safe() {
341+
// Get the latch out
342+
let latch = job.latch();
343+
drop(state_lock);
344+
345+
// Only call `wait_for_query` if we're using a Rayon thread pool
346+
// as it will attempt to mark the worker thread as blocked.
347+
return wait_for_query(query, qcx, span, key, latch, current_job_id);
348+
}
349+
341350
let id = job.id;
342351
drop(state_lock);
343352

344353
// If we are single-threaded we know that we have cycle error,
345354
// so we just return the error.
346355
cycle_error(query, qcx, id, span)
347356
}
348-
#[cfg(parallel_compiler)]
349-
QueryResult::Started(job) => {
350-
// Get the latch out
351-
let latch = job.latch();
352-
drop(state_lock);
353-
354-
wait_for_query(query, qcx, span, key, latch, current_job_id)
355-
}
356357
QueryResult::Poisoned => FatalError.raise(),
357358
}
358359
}

0 commit comments

Comments
 (0)