Skip to content

Commit ff331d2

Browse files
committed
Rename HandleCycleError to CycleErrorHandling
1 parent 39052da commit ff331d2

File tree

8 files changed

+38
-35
lines changed

8 files changed

+38
-35
lines changed

compiler/rustc_middle/src/query/plumbing.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ use rustc_data_structures::sync::{AtomicU64, WorkerLocal};
44
use rustc_hir::def_id::{DefId, LocalDefId};
55
use rustc_hir::hir_id::OwnerId;
66
use rustc_macros::HashStable;
7-
use rustc_query_system::HandleCycleError;
87
use rustc_query_system::dep_graph::{DepNodeIndex, SerializedDepNodeIndex};
98
pub(crate) use rustc_query_system::query::QueryJobId;
10-
use rustc_query_system::query::*;
9+
use rustc_query_system::query::{CycleError, CycleErrorHandling, HashResult, QueryCache};
1110
use rustc_span::{ErrorGuaranteed, Span};
1211
pub use sealed::IntoQueryParam;
1312

@@ -23,7 +22,8 @@ pub struct DynamicQuery<'tcx, C: QueryCache> {
2322
pub name: &'static str,
2423
pub eval_always: bool,
2524
pub dep_kind: DepKind,
26-
pub handle_cycle_error: HandleCycleError,
25+
/// How this query deals with query cycle errors.
26+
pub cycle_error_handling: CycleErrorHandling,
2727
// Offset of this query's state field in the QueryStates struct
2828
pub query_state: usize,
2929
// Offset of this query's cache field in the QueryCaches struct

compiler/rustc_query_impl/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ use rustc_middle::query::{
1818
queries,
1919
};
2020
use rustc_middle::ty::TyCtxt;
21+
use rustc_query_system::Value;
2122
use rustc_query_system::dep_graph::SerializedDepNodeIndex;
2223
use rustc_query_system::ich::StableHashingContext;
2324
use rustc_query_system::query::{
24-
CycleError, HashResult, QueryCache, QueryConfig, QueryMap, QueryMode, QueryState,
25-
get_query_incr, get_query_non_incr,
25+
CycleError, CycleErrorHandling, HashResult, QueryCache, QueryConfig, QueryMap, QueryMode,
26+
QueryState, get_query_incr, get_query_non_incr,
2627
};
27-
use rustc_query_system::{HandleCycleError, Value};
2828
use rustc_span::{ErrorGuaranteed, Span};
2929

3030
use crate::plumbing::{__rust_begin_short_backtrace, encode_all_query_results, try_mark_green};
@@ -181,8 +181,8 @@ where
181181
}
182182

183183
#[inline(always)]
184-
fn handle_cycle_error(self) -> HandleCycleError {
185-
self.dynamic.handle_cycle_error
184+
fn cycle_error_handling(self) -> CycleErrorHandling {
185+
self.dynamic.cycle_error_handling
186186
}
187187

188188
#[inline(always)]

compiler/rustc_query_impl/src/plumbing.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -199,21 +199,21 @@ pub fn query_key_hash_verify_all<'tcx>(tcx: TyCtxt<'tcx>) {
199199
}
200200
}
201201

202-
macro_rules! handle_cycle_error {
202+
macro_rules! cycle_error_handling {
203203
([]) => {{
204-
rustc_query_system::HandleCycleError::Error
204+
rustc_query_system::query::CycleErrorHandling::Error
205205
}};
206206
([(cycle_fatal) $($rest:tt)*]) => {{
207-
rustc_query_system::HandleCycleError::Fatal
207+
rustc_query_system::query::CycleErrorHandling::Fatal
208208
}};
209209
([(cycle_stash) $($rest:tt)*]) => {{
210-
rustc_query_system::HandleCycleError::Stash
210+
rustc_query_system::query::CycleErrorHandling::Stash
211211
}};
212212
([(cycle_delay_bug) $($rest:tt)*]) => {{
213-
rustc_query_system::HandleCycleError::DelayBug
213+
rustc_query_system::query::CycleErrorHandling::DelayBug
214214
}};
215215
([$other:tt $($modifiers:tt)*]) => {
216-
handle_cycle_error!([$($modifiers)*])
216+
cycle_error_handling!([$($modifiers)*])
217217
};
218218
}
219219

@@ -618,7 +618,7 @@ macro_rules! define_queries {
618618
name: stringify!($name),
619619
eval_always: is_eval_always!([$($modifiers)*]),
620620
dep_kind: dep_graph::dep_kinds::$name,
621-
handle_cycle_error: handle_cycle_error!([$($modifiers)*]),
621+
cycle_error_handling: cycle_error_handling!([$($modifiers)*]),
622622
query_state: std::mem::offset_of!(QueryStates<'tcx>, $name),
623623
query_cache: std::mem::offset_of!(QueryCaches<'tcx>, $name),
624624
cache_on_disk: |tcx, key| ::rustc_middle::query::cached::$name(tcx, key),

compiler/rustc_query_system/src/error.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,6 @@ pub(crate) struct CycleStack {
1111
pub desc: String,
1212
}
1313

14-
#[derive(Copy, Clone)]
15-
pub enum HandleCycleError {
16-
Error,
17-
Fatal,
18-
DelayBug,
19-
Stash,
20-
}
21-
2214
#[derive(Subdiagnostic)]
2315
pub(crate) enum StackCount {
2416
#[note(query_system_cycle_stack_single)]

compiler/rustc_query_system/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub mod ich;
1212
pub mod query;
1313
mod values;
1414

15-
pub use error::{HandleCycleError, QueryOverflow, QueryOverflowNote};
15+
pub use error::{QueryOverflow, QueryOverflowNote};
1616
pub use values::Value;
1717

1818
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }

compiler/rustc_query_system/src/query/config.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ use rustc_data_structures::fingerprint::Fingerprint;
77
use rustc_span::ErrorGuaranteed;
88

99
use crate::dep_graph::{DepKind, DepNode, DepNodeParams, SerializedDepNodeIndex};
10-
use crate::error::HandleCycleError;
1110
use crate::ich::StableHashingContext;
1211
use crate::query::caches::QueryCache;
13-
use crate::query::{CycleError, DepNodeIndex, QueryContext, QueryState};
12+
use crate::query::{CycleError, CycleErrorHandling, DepNodeIndex, QueryContext, QueryState};
1413

1514
pub type HashResult<V> = Option<fn(&mut StableHashingContext<'_>, &V) -> Fingerprint>;
1615

@@ -67,7 +66,7 @@ pub trait QueryConfig<Qcx: QueryContext>: Copy {
6766
fn feedable(self) -> bool;
6867

6968
fn dep_kind(self) -> DepKind;
70-
fn handle_cycle_error(self) -> HandleCycleError;
69+
fn cycle_error_handling(self) -> CycleErrorHandling;
7170
fn hash_result(self) -> HashResult<Self::Value>;
7271

7372
// Just here for convenience and checking that the key matches the kind, don't override this.

compiler/rustc_query_system/src/query/mod.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,18 @@ mod config;
2020
mod job;
2121
mod plumbing;
2222

23+
/// How a particular query deals with query cycle errors.
24+
///
25+
/// Inspected by the code that actually handles cycle errors, to decide what
26+
/// approach to use.
27+
#[derive(Copy, Clone)]
28+
pub enum CycleErrorHandling {
29+
Error,
30+
Fatal,
31+
DelayBug,
32+
Stash,
33+
}
34+
2335
/// Description of a frame in the query stack.
2436
///
2537
/// This is mostly used in case of cycles for error reporting.

compiler/rustc_query_system/src/query/plumbing.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ use rustc_span::{DUMMY_SP, Span};
1919
use tracing::instrument;
2020

2121
use super::QueryConfig;
22-
use crate::HandleCycleError;
2322
use crate::dep_graph::{DepContext, DepGraphData, DepNode, DepNodeIndex, DepNodeParams};
2423
use crate::ich::StableHashingContext;
2524
use crate::query::caches::QueryCache;
2625
use crate::query::job::{QueryInfo, QueryJob, QueryJobId, QueryJobInfo, QueryLatch, report_cycle};
27-
use crate::query::{QueryContext, QueryMap, QueryStackFrame, SerializedDepNodeIndex};
26+
use crate::query::{
27+
CycleErrorHandling, QueryContext, QueryMap, QueryStackFrame, SerializedDepNodeIndex,
28+
};
2829

2930
#[inline]
3031
fn equivalent_key<K: Eq, V>(k: &K) -> impl Fn(&(K, V)) -> bool + '_ {
@@ -142,22 +143,21 @@ where
142143
Q: QueryConfig<Qcx>,
143144
Qcx: QueryContext,
144145
{
145-
use HandleCycleError::*;
146-
match query.handle_cycle_error() {
147-
Error => {
146+
match query.cycle_error_handling() {
147+
CycleErrorHandling::Error => {
148148
let guar = error.emit();
149149
query.value_from_cycle_error(*qcx.dep_context(), cycle_error, guar)
150150
}
151-
Fatal => {
151+
CycleErrorHandling::Fatal => {
152152
error.emit();
153153
qcx.dep_context().sess().dcx().abort_if_errors();
154154
unreachable!()
155155
}
156-
DelayBug => {
156+
CycleErrorHandling::DelayBug => {
157157
let guar = error.delay_as_bug();
158158
query.value_from_cycle_error(*qcx.dep_context(), cycle_error, guar)
159159
}
160-
Stash => {
160+
CycleErrorHandling::Stash => {
161161
let guar = if let Some(root) = cycle_error.cycle.first()
162162
&& let Some(span) = root.query.span
163163
{

0 commit comments

Comments
 (0)