@@ -12,13 +12,13 @@ use crate::query::job::{report_cycle, QueryInfo, QueryJob, QueryJobId, QueryJobI
12
12
use crate :: query:: SerializedDepNodeIndex ;
13
13
use crate :: query:: { QueryContext , QueryMap , QuerySideEffects , QueryStackFrame } ;
14
14
use crate :: HandleCycleError ;
15
- #[ cfg( parallel_compiler) ]
16
- use rustc_data_structures:: cold_path;
17
15
use rustc_data_structures:: fingerprint:: Fingerprint ;
18
16
use rustc_data_structures:: fx:: FxHashMap ;
19
17
use rustc_data_structures:: sharded:: Sharded ;
20
18
use rustc_data_structures:: stack:: ensure_sufficient_stack;
21
19
use rustc_data_structures:: sync:: Lock ;
20
+ #[ cfg( parallel_compiler) ]
21
+ use rustc_data_structures:: { cold_path, sync} ;
22
22
use rustc_errors:: { DiagnosticBuilder , ErrorGuaranteed , FatalError } ;
23
23
use rustc_span:: { Span , DUMMY_SP } ;
24
24
use std:: cell:: Cell ;
@@ -223,7 +223,6 @@ where
223
223
224
224
#[ cold]
225
225
#[ inline( never) ]
226
- #[ cfg( not( parallel_compiler) ) ]
227
226
fn cycle_error < Q , Qcx > (
228
227
query : Q ,
229
228
qcx : Qcx ,
@@ -336,23 +335,25 @@ where
336
335
}
337
336
Entry :: Occupied ( mut entry) => {
338
337
match entry. get_mut ( ) {
339
- #[ cfg( not( parallel_compiler) ) ]
340
338
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
+
341
350
let id = job. id ;
342
351
drop ( state_lock) ;
343
352
344
353
// If we are single-threaded we know that we have cycle error,
345
354
// so we just return the error.
346
355
cycle_error ( query, qcx, id, span)
347
356
}
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
- }
356
357
QueryResult :: Poisoned => FatalError . raise ( ) ,
357
358
}
358
359
}
0 commit comments