@@ -12,16 +12,14 @@ 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;
15
17
use rustc_data_structures:: fingerprint:: Fingerprint ;
16
18
use rustc_data_structures:: fx:: FxHashMap ;
17
- use rustc_data_structures:: stack:: ensure_sufficient_stack;
18
- use rustc_data_structures:: sync:: Lock ;
19
- #[ cfg( parallel_compiler) ]
20
- use rustc_data_structures:: { cold_path, sharded:: Sharded } ;
21
- use rustc_data_structures:: profiling:: TimingGuard ;
22
19
use rustc_data_structures:: sharded:: Sharded ;
23
20
use rustc_data_structures:: stack:: ensure_sufficient_stack;
24
- use rustc_data_structures:: sync:: { Lock , LockGuard } ; use rustc_errors:: { DiagnosticBuilder , ErrorGuaranteed , FatalError } ;
21
+ use rustc_data_structures:: sync:: Lock ;
22
+ use rustc_errors:: { DiagnosticBuilder , ErrorGuaranteed , FatalError } ;
25
23
use rustc_span:: { Span , DUMMY_SP } ;
26
24
use std:: cell:: Cell ;
27
25
use std:: collections:: hash_map:: Entry ;
@@ -227,7 +225,6 @@ where
227
225
228
226
#[ cold]
229
227
#[ inline( never) ]
230
- #[ cfg( not( parallel_compiler) ) ]
231
228
fn cycle_error < Q , Qcx > (
232
229
query : Q ,
233
230
qcx : Qcx ,
@@ -298,7 +295,6 @@ where
298
295
{
299
296
let state = query. query_state ( qcx) ;
300
297
let mut state_lock = state. active . get_shard_by_value ( & key) . lock ( ) ;
301
- let mut state_lock = state. active . get_shard_by_value ( & key) . lock ( ) ;
302
298
// For the parallel compiler we need to check both the query cache and query state structures
303
299
// while holding the state lock to ensure that 1) the query has not yet completed and 2) the
304
300
// query is not still executing. Without checking the query cache here, we can end up
@@ -340,6 +336,14 @@ where
340
336
}
341
337
#[ cfg( parallel_compiler) ]
342
338
QueryResult :: Started ( job) => {
339
+ if !rustc_data_structures:: sync:: active ( ) {
340
+ let id = job. id ;
341
+ drop ( state_lock) ;
342
+
343
+ // If we are single-threaded we know that we have cycle error,
344
+ // so we just return the error.
345
+ return cycle_error ( query, qcx, id, span) ;
346
+ }
343
347
// Get the latch out
344
348
let latch = job. latch ( ) ;
345
349
drop ( state_lock) ;
0 commit comments