Skip to content

Commit 0932068

Browse files
committed
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.
1 parent 7bcb7a2 commit 0932068

File tree

7 files changed

+32
-26
lines changed

7 files changed

+32
-26
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4534,9 +4534,11 @@ version = "0.0.0"
45344534
dependencies = [
45354535
"measureme",
45364536
"rustc_data_structures",
4537+
"rustc_errors",
45374538
"rustc_hashes",
45384539
"rustc_hir",
45394540
"rustc_index",
4541+
"rustc_macros",
45404542
"rustc_middle",
45414543
"rustc_query_system",
45424544
"rustc_serialize",

compiler/rustc_query_impl/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ edition = "2024"
77
# tidy-alphabetical-start
88
measureme = "12.0.1"
99
rustc_data_structures = { path = "../rustc_data_structures" }
10+
rustc_errors = { path = "../rustc_errors" }
1011
rustc_hashes = { path = "../rustc_hashes" }
1112
rustc_hir = { path = "../rustc_hir" }
1213
rustc_index = { path = "../rustc_index" }
14+
rustc_macros = { path = "../rustc_macros" }
1315
rustc_middle = { path = "../rustc_middle" }
1416
rustc_query_system = { path = "../rustc_query_system" }
1517
rustc_serialize = { path = "../rustc_serialize" }
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
use rustc_hir::limit::Limit;
2+
use rustc_macros::{Diagnostic, Subdiagnostic};
3+
use rustc_span::{Span, Symbol};
4+
5+
#[derive(Diagnostic)]
6+
#[help(
7+
"consider increasing the recursion limit by adding a `#![recursion_limit = \"{$suggested_limit}\"]` attribute to your crate (`{$crate_name}`)"
8+
)]
9+
#[diag("queries overflow the depth limit!")]
10+
pub(crate) struct QueryOverflow {
11+
#[primary_span]
12+
pub span: Span,
13+
#[subdiagnostic]
14+
pub note: QueryOverflowNote,
15+
pub suggested_limit: Limit,
16+
pub crate_name: Symbol,
17+
}
18+
19+
#[derive(Subdiagnostic)]
20+
#[note("query depth increased by {$depth} when {$desc}")]
21+
pub(crate) struct QueryOverflowNote {
22+
pub desc: String,
23+
pub depth: usize,
24+
}

compiler/rustc_query_impl/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ pub use crate::plumbing::{QueryCtxt, query_key_hash_verify_all};
3939
mod profiling_support;
4040
pub use self::profiling_support::alloc_self_profile_query_strings;
4141

42+
mod error;
43+
4244
#[derive(ConstParamTy)] // Allow this struct to be used for const-generic values.
4345
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
4446
struct QueryFlags {

compiler/rustc_query_impl/src/plumbing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ use rustc_query_system::query::{
3030
QueryCache, QueryContext, QueryDispatcher, QueryJobId, QueryMap, QuerySideEffect,
3131
QueryStackDeferred, QueryStackFrame, QueryStackFrameExtra, force_query,
3232
};
33-
use rustc_query_system::{QueryOverflow, QueryOverflowNote};
3433
use rustc_serialize::{Decodable, Encodable};
3534
use rustc_span::def_id::LOCAL_CRATE;
3635

3736
use crate::QueryDispatcherUnerased;
37+
use crate::error::{QueryOverflow, QueryOverflowNote};
3838

3939
/// Implements [`QueryContext`] for use by [`rustc_query_system`], since that
4040
/// crate does not have direct access to [`TyCtxt`].

compiler/rustc_query_system/src/error.rs

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use rustc_errors::codes::*;
2-
use rustc_hir::limit::Limit;
32
use rustc_macros::{Diagnostic, Subdiagnostic};
4-
use rustc_span::{Span, Symbol};
3+
use rustc_span::Span;
54

65
#[derive(Subdiagnostic)]
76
#[note("...which requires {$desc}...")]
@@ -75,24 +74,3 @@ pub(crate) struct IncrementCompilation {
7574
pub run_cmd: String,
7675
pub dep_node: String,
7776
}
78-
79-
#[derive(Diagnostic)]
80-
#[help(
81-
"consider increasing the recursion limit by adding a `#![recursion_limit = \"{$suggested_limit}\"]` attribute to your crate (`{$crate_name}`)"
82-
)]
83-
#[diag("queries overflow the depth limit!")]
84-
pub struct QueryOverflow {
85-
#[primary_span]
86-
pub span: Span,
87-
#[subdiagnostic]
88-
pub note: QueryOverflowNote,
89-
pub suggested_limit: Limit,
90-
pub crate_name: Symbol,
91-
}
92-
93-
#[derive(Subdiagnostic)]
94-
#[note("query depth increased by {$depth} when {$desc}")]
95-
pub struct QueryOverflowNote {
96-
pub desc: String,
97-
pub depth: usize,
98-
}

compiler/rustc_query_system/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,3 @@ pub mod dep_graph;
1010
mod error;
1111
pub mod ich;
1212
pub mod query;
13-
14-
pub use error::{QueryOverflow, QueryOverflowNote};

0 commit comments

Comments
 (0)