Skip to content

Commit 53ccfb2

Browse files
committed
rebase
1 parent e166006 commit 53ccfb2

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

compiler/rustc_query_system/src/query/plumbing.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,14 @@ 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;
1517
use rustc_data_structures::fingerprint::Fingerprint;
1618
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;
2219
use rustc_data_structures::sharded::Sharded;
2320
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};
2523
use rustc_span::{Span, DUMMY_SP};
2624
use std::cell::Cell;
2725
use std::collections::hash_map::Entry;
@@ -227,7 +225,6 @@ where
227225

228226
#[cold]
229227
#[inline(never)]
230-
#[cfg(not(parallel_compiler))]
231228
fn cycle_error<Q, Qcx>(
232229
query: Q,
233230
qcx: Qcx,
@@ -298,7 +295,6 @@ where
298295
{
299296
let state = query.query_state(qcx);
300297
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();
302298
// For the parallel compiler we need to check both the query cache and query state structures
303299
// while holding the state lock to ensure that 1) the query has not yet completed and 2) the
304300
// query is not still executing. Without checking the query cache here, we can end up
@@ -340,6 +336,14 @@ where
340336
}
341337
#[cfg(parallel_compiler)]
342338
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+
}
343347
// Get the latch out
344348
let latch = job.latch();
345349
drop(state_lock);

0 commit comments

Comments
 (0)