Skip to content

Commit 30f82aa

Browse files
Convert to inline diagnostics in rustc_query_system
1 parent 5e30860 commit 30f82aa

7 files changed

Lines changed: 27 additions & 56 deletions

File tree

Cargo.lock

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3812,7 +3812,6 @@ dependencies = [
38123812
"rustc_pattern_analysis",
38133813
"rustc_privacy",
38143814
"rustc_public",
3815-
"rustc_query_system",
38163815
"rustc_resolve",
38173816
"rustc_session",
38183817
"rustc_span",
@@ -4572,7 +4571,6 @@ dependencies = [
45724571
"rustc_data_structures",
45734572
"rustc_errors",
45744573
"rustc_feature",
4575-
"rustc_fluent_macro",
45764574
"rustc_hashes",
45774575
"rustc_hir",
45784576
"rustc_index",

compiler/rustc_driver_impl/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ rustc_passes = { path = "../rustc_passes" }
4444
rustc_pattern_analysis = { path = "../rustc_pattern_analysis" }
4545
rustc_privacy = { path = "../rustc_privacy" }
4646
rustc_public = { path = "../rustc_public", features = ["rustc_internal"] }
47-
rustc_query_system = { path = "../rustc_query_system" }
4847
rustc_resolve = { path = "../rustc_resolve" }
4948
rustc_session = { path = "../rustc_session" }
5049
rustc_span = { path = "../rustc_span" }

compiler/rustc_driver_impl/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ pub static DEFAULT_LOCALE_RESOURCES: &[&str] = &[
142142
rustc_passes::DEFAULT_LOCALE_RESOURCE,
143143
rustc_pattern_analysis::DEFAULT_LOCALE_RESOURCE,
144144
rustc_privacy::DEFAULT_LOCALE_RESOURCE,
145-
rustc_query_system::DEFAULT_LOCALE_RESOURCE,
146145
rustc_resolve::DEFAULT_LOCALE_RESOURCE,
147146
rustc_session::DEFAULT_LOCALE_RESOURCE,
148147
rustc_trait_selection::DEFAULT_LOCALE_RESOURCE,

compiler/rustc_query_system/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ rustc_ast = { path = "../rustc_ast" }
1111
rustc_data_structures = { path = "../rustc_data_structures" }
1212
rustc_errors = { path = "../rustc_errors" }
1313
rustc_feature = { path = "../rustc_feature" }
14-
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
1514
rustc_hashes = { path = "../rustc_hashes" }
1615
rustc_hir = { path = "../rustc_hir" }
1716
rustc_index = { path = "../rustc_index" }

compiler/rustc_query_system/messages.ftl

Lines changed: 0 additions & 30 deletions
This file was deleted.

compiler/rustc_query_system/src/error.rs

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use rustc_macros::{Diagnostic, Subdiagnostic};
44
use rustc_span::{Span, Symbol};
55

66
#[derive(Subdiagnostic)]
7-
#[note(query_system_cycle_stack_middle)]
7+
#[note("...which requires {$desc}...")]
88
pub(crate) struct CycleStack {
99
#[primary_span]
1010
pub span: Span,
@@ -13,32 +13,34 @@ pub(crate) struct CycleStack {
1313

1414
#[derive(Subdiagnostic)]
1515
pub(crate) enum StackCount {
16-
#[note(query_system_cycle_stack_single)]
16+
#[note("...which immediately requires {$stack_bottom} again")]
1717
Single,
18-
#[note(query_system_cycle_stack_multiple)]
18+
#[note("...which again requires {$stack_bottom}, completing the cycle")]
1919
Multiple,
2020
}
2121

2222
#[derive(Subdiagnostic)]
2323
pub(crate) enum Alias {
24-
#[note(query_system_cycle_recursive_ty_alias)]
25-
#[help(query_system_cycle_recursive_ty_alias_help1)]
26-
#[help(query_system_cycle_recursive_ty_alias_help2)]
24+
#[note("type aliases cannot be recursive")]
25+
#[help("consider using a struct, enum, or union instead to break the cycle")]
26+
#[help(
27+
"see <https://doc.rust-lang.org/reference/types.html#recursive-types> for more information"
28+
)]
2729
Ty,
28-
#[note(query_system_cycle_recursive_trait_alias)]
30+
#[note("trait aliases cannot be recursive")]
2931
Trait,
3032
}
3133

3234
#[derive(Subdiagnostic)]
33-
#[note(query_system_cycle_usage)]
35+
#[note("cycle used when {$usage}")]
3436
pub(crate) struct CycleUsage {
3537
#[primary_span]
3638
pub span: Span,
3739
pub usage: String,
3840
}
3941

4042
#[derive(Diagnostic)]
41-
#[diag(query_system_cycle, code = E0391)]
43+
#[diag("cycle detected when {$stack_bottom}", code = E0391)]
4244
pub(crate) struct Cycle {
4345
#[primary_span]
4446
pub span: Span,
@@ -51,28 +53,34 @@ pub(crate) struct Cycle {
5153
pub alias: Option<Alias>,
5254
#[subdiagnostic]
5355
pub cycle_usage: Option<CycleUsage>,
54-
#[note]
56+
#[note(
57+
"see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information"
58+
)]
5559
pub note_span: (),
5660
}
5761

5862
#[derive(Diagnostic)]
59-
#[diag(query_system_reentrant)]
63+
#[diag("internal compiler error: reentrant incremental verify failure, suppressing message")]
6064
pub(crate) struct Reentrant;
6165

6266
#[derive(Diagnostic)]
63-
#[diag(query_system_increment_compilation)]
64-
#[note(query_system_increment_compilation_note1)]
65-
#[note(query_system_increment_compilation_note2)]
66-
#[note(query_system_increment_compilation_note3)]
67-
#[note(query_system_increment_compilation_note4)]
67+
#[diag("internal compiler error: encountered incremental compilation error with {$dep_node}")]
68+
#[note("please follow the instructions below to create a bug report with the provided information")]
69+
#[note("for incremental compilation bugs, having a reproduction is vital")]
70+
#[note(
71+
"an ideal reproduction consists of the code before and some patch that then triggers the bug when applied and compiled again"
72+
)]
73+
#[note("as a workaround, you can run {$run_cmd} to allow your project to compile")]
6874
pub(crate) struct IncrementCompilation {
6975
pub run_cmd: String,
7076
pub dep_node: String,
7177
}
7278

7379
#[derive(Diagnostic)]
74-
#[help]
75-
#[diag(query_system_query_overflow)]
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!")]
7684
pub struct QueryOverflow {
7785
#[primary_span]
7886
pub span: Span,
@@ -83,7 +91,7 @@ pub struct QueryOverflow {
8391
}
8492

8593
#[derive(Subdiagnostic)]
86-
#[note(query_system_overflow_note)]
94+
#[note("query depth increased by {$depth} when {$desc}")]
8795
pub struct QueryOverflowNote {
8896
pub desc: String,
8997
pub depth: usize,

compiler/rustc_query_system/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,3 @@ mod values;
1414

1515
pub use error::{QueryOverflow, QueryOverflowNote};
1616
pub use values::Value;
17-
18-
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }

0 commit comments

Comments
 (0)