Move the QueryOverflow and QueryOverflowNote errors.
They are defined in `rustc_query_system` but used in `rustc_query_impl`. This is very much *not* how things are supposed to be done; I suspect someone got lazy and took a shortcut at some point. This commit moves the errors into `rustc_query_impl`. This requires more lines of code to give `rustc_query_impl` an errors module, but it's worthwhile to do things in the normal way instead of a weird exceptional way.
This commit is contained in:
parent
7bcb7a281e
commit
0932068b6c
7 changed files with 32 additions and 26 deletions
|
|
@ -4534,9 +4534,11 @@ version = "0.0.0"
|
|||
dependencies = [
|
||||
"measureme",
|
||||
"rustc_data_structures",
|
||||
"rustc_errors",
|
||||
"rustc_hashes",
|
||||
"rustc_hir",
|
||||
"rustc_index",
|
||||
"rustc_macros",
|
||||
"rustc_middle",
|
||||
"rustc_query_system",
|
||||
"rustc_serialize",
|
||||
|
|
|
|||
|
|
@ -7,9 +7,11 @@ edition = "2024"
|
|||
# tidy-alphabetical-start
|
||||
measureme = "12.0.1"
|
||||
rustc_data_structures = { path = "../rustc_data_structures" }
|
||||
rustc_errors = { path = "../rustc_errors" }
|
||||
rustc_hashes = { path = "../rustc_hashes" }
|
||||
rustc_hir = { path = "../rustc_hir" }
|
||||
rustc_index = { path = "../rustc_index" }
|
||||
rustc_macros = { path = "../rustc_macros" }
|
||||
rustc_middle = { path = "../rustc_middle" }
|
||||
rustc_query_system = { path = "../rustc_query_system" }
|
||||
rustc_serialize = { path = "../rustc_serialize" }
|
||||
|
|
|
|||
24
compiler/rustc_query_impl/src/error.rs
Normal file
24
compiler/rustc_query_impl/src/error.rs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
use rustc_hir::limit::Limit;
|
||||
use rustc_macros::{Diagnostic, Subdiagnostic};
|
||||
use rustc_span::{Span, Symbol};
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[help(
|
||||
"consider increasing the recursion limit by adding a `#![recursion_limit = \"{$suggested_limit}\"]` attribute to your crate (`{$crate_name}`)"
|
||||
)]
|
||||
#[diag("queries overflow the depth limit!")]
|
||||
pub(crate) struct QueryOverflow {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
#[subdiagnostic]
|
||||
pub note: QueryOverflowNote,
|
||||
pub suggested_limit: Limit,
|
||||
pub crate_name: Symbol,
|
||||
}
|
||||
|
||||
#[derive(Subdiagnostic)]
|
||||
#[note("query depth increased by {$depth} when {$desc}")]
|
||||
pub(crate) struct QueryOverflowNote {
|
||||
pub desc: String,
|
||||
pub depth: usize,
|
||||
}
|
||||
|
|
@ -39,6 +39,8 @@ pub use crate::plumbing::{QueryCtxt, query_key_hash_verify_all};
|
|||
mod profiling_support;
|
||||
pub use self::profiling_support::alloc_self_profile_query_strings;
|
||||
|
||||
mod error;
|
||||
|
||||
#[derive(ConstParamTy)] // Allow this struct to be used for const-generic values.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
struct QueryFlags {
|
||||
|
|
|
|||
|
|
@ -30,11 +30,11 @@ use rustc_query_system::query::{
|
|||
QueryCache, QueryContext, QueryDispatcher, QueryJobId, QueryMap, QuerySideEffect,
|
||||
QueryStackDeferred, QueryStackFrame, QueryStackFrameExtra, force_query,
|
||||
};
|
||||
use rustc_query_system::{QueryOverflow, QueryOverflowNote};
|
||||
use rustc_serialize::{Decodable, Encodable};
|
||||
use rustc_span::def_id::LOCAL_CRATE;
|
||||
|
||||
use crate::QueryDispatcherUnerased;
|
||||
use crate::error::{QueryOverflow, QueryOverflowNote};
|
||||
|
||||
/// Implements [`QueryContext`] for use by [`rustc_query_system`], since that
|
||||
/// crate does not have direct access to [`TyCtxt`].
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
use rustc_errors::codes::*;
|
||||
use rustc_hir::limit::Limit;
|
||||
use rustc_macros::{Diagnostic, Subdiagnostic};
|
||||
use rustc_span::{Span, Symbol};
|
||||
use rustc_span::Span;
|
||||
|
||||
#[derive(Subdiagnostic)]
|
||||
#[note("...which requires {$desc}...")]
|
||||
|
|
@ -75,24 +74,3 @@ pub(crate) struct IncrementCompilation {
|
|||
pub run_cmd: String,
|
||||
pub dep_node: String,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[help(
|
||||
"consider increasing the recursion limit by adding a `#![recursion_limit = \"{$suggested_limit}\"]` attribute to your crate (`{$crate_name}`)"
|
||||
)]
|
||||
#[diag("queries overflow the depth limit!")]
|
||||
pub struct QueryOverflow {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
#[subdiagnostic]
|
||||
pub note: QueryOverflowNote,
|
||||
pub suggested_limit: Limit,
|
||||
pub crate_name: Symbol,
|
||||
}
|
||||
|
||||
#[derive(Subdiagnostic)]
|
||||
#[note("query depth increased by {$depth} when {$desc}")]
|
||||
pub struct QueryOverflowNote {
|
||||
pub desc: String,
|
||||
pub depth: usize,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,5 +10,3 @@ pub mod dep_graph;
|
|||
mod error;
|
||||
pub mod ich;
|
||||
pub mod query;
|
||||
|
||||
pub use error::{QueryOverflow, QueryOverflowNote};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue