@@ -12,13 +12,13 @@ use crate::query::job::{report_cycle, QueryInfo, QueryJob, QueryJobId, QueryJobI
1212use crate :: query:: SerializedDepNodeIndex ;
1313use crate :: query:: { QueryContext , QueryMap , QuerySideEffects , QueryStackFrame } ;
1414use crate :: HandleCycleError ;
15- #[ cfg( parallel_compiler) ]
16- use rustc_data_structures:: cold_path;
1715use rustc_data_structures:: fingerprint:: Fingerprint ;
1816use rustc_data_structures:: fx:: FxHashMap ;
1917use rustc_data_structures:: sharded:: Sharded ;
2018use rustc_data_structures:: stack:: ensure_sufficient_stack;
2119use rustc_data_structures:: sync:: Lock ;
20+ #[ cfg( parallel_compiler) ]
21+ use rustc_data_structures:: { cold_path, sync} ;
2222use rustc_errors:: { DiagnosticBuilder , ErrorGuaranteed , FatalError } ;
2323use rustc_span:: { Span , DUMMY_SP } ;
2424use std:: cell:: Cell ;
@@ -223,7 +223,6 @@ where
223223
224224#[ cold]
225225#[ inline( never) ]
226- #[ cfg( not( parallel_compiler) ) ]
227226fn 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