mirror of
https://github.com/rust-lang/rust.git
synced 2026-01-24 23:17:31 +00:00
Rename HandleCycleError to CycleErrorHandling
This commit is contained in:
@@ -4,10 +4,9 @@ use rustc_data_structures::sync::{AtomicU64, WorkerLocal};
|
||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
use rustc_hir::hir_id::OwnerId;
|
||||
use rustc_macros::HashStable;
|
||||
use rustc_query_system::HandleCycleError;
|
||||
use rustc_query_system::dep_graph::{DepNodeIndex, SerializedDepNodeIndex};
|
||||
pub(crate) use rustc_query_system::query::QueryJobId;
|
||||
use rustc_query_system::query::*;
|
||||
use rustc_query_system::query::{CycleError, CycleErrorHandling, HashResult, QueryCache};
|
||||
use rustc_span::{ErrorGuaranteed, Span};
|
||||
pub use sealed::IntoQueryParam;
|
||||
|
||||
@@ -23,7 +22,8 @@ pub struct DynamicQuery<'tcx, C: QueryCache> {
|
||||
pub name: &'static str,
|
||||
pub eval_always: bool,
|
||||
pub dep_kind: DepKind,
|
||||
pub handle_cycle_error: HandleCycleError,
|
||||
/// How this query deals with query cycle errors.
|
||||
pub cycle_error_handling: CycleErrorHandling,
|
||||
// Offset of this query's state field in the QueryStates struct
|
||||
pub query_state: usize,
|
||||
// Offset of this query's cache field in the QueryCaches struct
|
||||
|
||||
@@ -18,13 +18,13 @@ use rustc_middle::query::{
|
||||
queries,
|
||||
};
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_query_system::Value;
|
||||
use rustc_query_system::dep_graph::SerializedDepNodeIndex;
|
||||
use rustc_query_system::ich::StableHashingContext;
|
||||
use rustc_query_system::query::{
|
||||
CycleError, HashResult, QueryCache, QueryConfig, QueryMap, QueryMode, QueryState,
|
||||
get_query_incr, get_query_non_incr,
|
||||
CycleError, CycleErrorHandling, HashResult, QueryCache, QueryConfig, QueryMap, QueryMode,
|
||||
QueryState, get_query_incr, get_query_non_incr,
|
||||
};
|
||||
use rustc_query_system::{HandleCycleError, Value};
|
||||
use rustc_span::{ErrorGuaranteed, Span};
|
||||
|
||||
use crate::plumbing::{__rust_begin_short_backtrace, encode_all_query_results, try_mark_green};
|
||||
@@ -181,8 +181,8 @@ where
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn handle_cycle_error(self) -> HandleCycleError {
|
||||
self.dynamic.handle_cycle_error
|
||||
fn cycle_error_handling(self) -> CycleErrorHandling {
|
||||
self.dynamic.cycle_error_handling
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
|
||||
@@ -199,21 +199,21 @@ pub fn query_key_hash_verify_all<'tcx>(tcx: TyCtxt<'tcx>) {
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! handle_cycle_error {
|
||||
macro_rules! cycle_error_handling {
|
||||
([]) => {{
|
||||
rustc_query_system::HandleCycleError::Error
|
||||
rustc_query_system::query::CycleErrorHandling::Error
|
||||
}};
|
||||
([(cycle_fatal) $($rest:tt)*]) => {{
|
||||
rustc_query_system::HandleCycleError::Fatal
|
||||
rustc_query_system::query::CycleErrorHandling::Fatal
|
||||
}};
|
||||
([(cycle_stash) $($rest:tt)*]) => {{
|
||||
rustc_query_system::HandleCycleError::Stash
|
||||
rustc_query_system::query::CycleErrorHandling::Stash
|
||||
}};
|
||||
([(cycle_delay_bug) $($rest:tt)*]) => {{
|
||||
rustc_query_system::HandleCycleError::DelayBug
|
||||
rustc_query_system::query::CycleErrorHandling::DelayBug
|
||||
}};
|
||||
([$other:tt $($modifiers:tt)*]) => {
|
||||
handle_cycle_error!([$($modifiers)*])
|
||||
cycle_error_handling!([$($modifiers)*])
|
||||
};
|
||||
}
|
||||
|
||||
@@ -618,7 +618,7 @@ macro_rules! define_queries {
|
||||
name: stringify!($name),
|
||||
eval_always: is_eval_always!([$($modifiers)*]),
|
||||
dep_kind: dep_graph::dep_kinds::$name,
|
||||
handle_cycle_error: handle_cycle_error!([$($modifiers)*]),
|
||||
cycle_error_handling: cycle_error_handling!([$($modifiers)*]),
|
||||
query_state: std::mem::offset_of!(QueryStates<'tcx>, $name),
|
||||
query_cache: std::mem::offset_of!(QueryCaches<'tcx>, $name),
|
||||
cache_on_disk: |tcx, key| ::rustc_middle::query::cached::$name(tcx, key),
|
||||
|
||||
@@ -11,14 +11,6 @@ pub(crate) struct CycleStack {
|
||||
pub desc: String,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
pub enum HandleCycleError {
|
||||
Error,
|
||||
Fatal,
|
||||
DelayBug,
|
||||
Stash,
|
||||
}
|
||||
|
||||
#[derive(Subdiagnostic)]
|
||||
pub(crate) enum StackCount {
|
||||
#[note(query_system_cycle_stack_single)]
|
||||
|
||||
@@ -12,7 +12,7 @@ pub mod ich;
|
||||
pub mod query;
|
||||
mod values;
|
||||
|
||||
pub use error::{HandleCycleError, QueryOverflow, QueryOverflowNote};
|
||||
pub use error::{QueryOverflow, QueryOverflowNote};
|
||||
pub use values::Value;
|
||||
|
||||
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
|
||||
|
||||
@@ -7,10 +7,9 @@ use rustc_data_structures::fingerprint::Fingerprint;
|
||||
use rustc_span::ErrorGuaranteed;
|
||||
|
||||
use crate::dep_graph::{DepKind, DepNode, DepNodeParams, SerializedDepNodeIndex};
|
||||
use crate::error::HandleCycleError;
|
||||
use crate::ich::StableHashingContext;
|
||||
use crate::query::caches::QueryCache;
|
||||
use crate::query::{CycleError, DepNodeIndex, QueryContext, QueryState};
|
||||
use crate::query::{CycleError, CycleErrorHandling, DepNodeIndex, QueryContext, QueryState};
|
||||
|
||||
pub type HashResult<V> = Option<fn(&mut StableHashingContext<'_>, &V) -> Fingerprint>;
|
||||
|
||||
@@ -67,7 +66,7 @@ pub trait QueryConfig<Qcx: QueryContext>: Copy {
|
||||
fn feedable(self) -> bool;
|
||||
|
||||
fn dep_kind(self) -> DepKind;
|
||||
fn handle_cycle_error(self) -> HandleCycleError;
|
||||
fn cycle_error_handling(self) -> CycleErrorHandling;
|
||||
fn hash_result(self) -> HashResult<Self::Value>;
|
||||
|
||||
// Just here for convenience and checking that the key matches the kind, don't override this.
|
||||
|
||||
@@ -20,6 +20,18 @@ mod config;
|
||||
mod job;
|
||||
mod plumbing;
|
||||
|
||||
/// How a particular query deals with query cycle errors.
|
||||
///
|
||||
/// Inspected by the code that actually handles cycle errors, to decide what
|
||||
/// approach to use.
|
||||
#[derive(Copy, Clone)]
|
||||
pub enum CycleErrorHandling {
|
||||
Error,
|
||||
Fatal,
|
||||
DelayBug,
|
||||
Stash,
|
||||
}
|
||||
|
||||
/// Description of a frame in the query stack.
|
||||
///
|
||||
/// This is mostly used in case of cycles for error reporting.
|
||||
|
||||
@@ -19,12 +19,13 @@ use rustc_span::{DUMMY_SP, Span};
|
||||
use tracing::instrument;
|
||||
|
||||
use super::QueryConfig;
|
||||
use crate::HandleCycleError;
|
||||
use crate::dep_graph::{DepContext, DepGraphData, DepNode, DepNodeIndex, DepNodeParams};
|
||||
use crate::ich::StableHashingContext;
|
||||
use crate::query::caches::QueryCache;
|
||||
use crate::query::job::{QueryInfo, QueryJob, QueryJobId, QueryJobInfo, QueryLatch, report_cycle};
|
||||
use crate::query::{QueryContext, QueryMap, QueryStackFrame, SerializedDepNodeIndex};
|
||||
use crate::query::{
|
||||
CycleErrorHandling, QueryContext, QueryMap, QueryStackFrame, SerializedDepNodeIndex,
|
||||
};
|
||||
|
||||
#[inline]
|
||||
fn equivalent_key<K: Eq, V>(k: &K) -> impl Fn(&(K, V)) -> bool + '_ {
|
||||
@@ -142,22 +143,21 @@ where
|
||||
Q: QueryConfig<Qcx>,
|
||||
Qcx: QueryContext,
|
||||
{
|
||||
use HandleCycleError::*;
|
||||
match query.handle_cycle_error() {
|
||||
Error => {
|
||||
match query.cycle_error_handling() {
|
||||
CycleErrorHandling::Error => {
|
||||
let guar = error.emit();
|
||||
query.value_from_cycle_error(*qcx.dep_context(), cycle_error, guar)
|
||||
}
|
||||
Fatal => {
|
||||
CycleErrorHandling::Fatal => {
|
||||
error.emit();
|
||||
qcx.dep_context().sess().dcx().abort_if_errors();
|
||||
unreachable!()
|
||||
}
|
||||
DelayBug => {
|
||||
CycleErrorHandling::DelayBug => {
|
||||
let guar = error.delay_as_bug();
|
||||
query.value_from_cycle_error(*qcx.dep_context(), cycle_error, guar)
|
||||
}
|
||||
Stash => {
|
||||
CycleErrorHandling::Stash => {
|
||||
let guar = if let Some(root) = cycle_error.cycle.first()
|
||||
&& let Some(span) = root.query.span
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user