Skip to content

Commit 22c5c83

Browse files
authoredAug 31, 2022
Rollup merge of #100844 - evopen:migrate-diag, r=davidtwco
migrate rustc_query_system to use SessionDiagnostic issues: * variable list is not supported in fluent * ~~cannot have two sub diagnostic with the same tag (eg. 2 .note or 2 .help)~~ allow multiple tag with SessionSubdiagnostic derive
2 parents 2af2cda + 7ce59eb commit 22c5c83

File tree

10 files changed

+475
-804
lines changed

10 files changed

+475
-804
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
query_system_reentrant = internal compiler error: re-entrant incremental verify failure, suppressing message
2+
3+
query_system_increment_compilation = internal compiler error: encountered incremental compilation error with {$dep_node}
4+
.help = This is a known issue with the compiler. Run {$run_cmd} to allow your project to compile
5+
6+
query_system_increment_compilation_note1 = Please follow the instructions below to create a bug report with the provided information
7+
query_system_increment_compilation_note2 = See <https://github.com/rust-lang/rust/issues/84970> for more information
8+
9+
query_system_cycle = cycle detected when {$stack_bottom}
10+
11+
query_system_cycle_usage = cycle used when {$usage}
12+
13+
query_system_cycle_stack_single = ...which immediately requires {$stack_bottom} again
14+
15+
query_system_cycle_stack_multiple = ...which again requires {$stack_bottom}, completing the cycle
16+
17+
query_system_cycle_recursive_ty_alias = type aliases cannot be recursive
18+
query_system_cycle_recursive_ty_alias_help1 = consider using a struct, enum, or union instead to break the cycle
19+
query_system_cycle_recursive_ty_alias_help2 = see <https://doc.rust-lang.org/reference/types.html#recursive-types> for more information
20+
21+
query_system_cycle_recursive_trait_alias = trait aliases cannot be recursive
22+
23+
query_system_cycle_which_requires = ...which requires {$desc}...
24+
25+
query_system_query_overflow = queries overflow the depth limit!

‎compiler/rustc_error_messages/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ fluent_messages! {
5050
passes => "../locales/en-US/passes.ftl",
5151
plugin_impl => "../locales/en-US/plugin_impl.ftl",
5252
privacy => "../locales/en-US/privacy.ftl",
53+
query_system => "../locales/en-US/query_system.ftl",
5354
save_analysis => "../locales/en-US/save_analysis.ftl",
5455
ty_utils => "../locales/en-US/ty_utils.ftl",
5556
typeck => "../locales/en-US/typeck.ftl",

‎compiler/rustc_macros/src/diagnostics/subdiagnostic.rs

+249-445
Large diffs are not rendered by default.
+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
use rustc_errors::AddSubdiagnostic;
2+
use rustc_span::Span;
3+
4+
pub struct CycleStack {
5+
pub span: Span,
6+
pub desc: String,
7+
}
8+
9+
impl AddSubdiagnostic for CycleStack {
10+
fn add_to_diagnostic(self, diag: &mut rustc_errors::Diagnostic) {
11+
diag.span_note(self.span, &format!("...which requires {}...", self.desc));
12+
}
13+
}
14+
15+
#[derive(SessionSubdiagnostic)]
16+
pub enum StackCount {
17+
#[note(query_system::cycle_stack_single)]
18+
Single,
19+
#[note(query_system::cycle_stack_multiple)]
20+
Multiple,
21+
}
22+
23+
#[derive(SessionSubdiagnostic)]
24+
pub enum Alias {
25+
#[note(query_system::cycle_recursive_ty_alias)]
26+
#[help(query_system::cycle_recursive_ty_alias_help1)]
27+
#[help(query_system::cycle_recursive_ty_alias_help2)]
28+
Ty,
29+
#[note(query_system::cycle_recursive_trait_alias)]
30+
Trait,
31+
}
32+
33+
#[derive(SessionSubdiagnostic)]
34+
#[note(query_system::cycle_usage)]
35+
pub struct CycleUsage {
36+
#[primary_span]
37+
pub span: Span,
38+
pub usage: String,
39+
}
40+
41+
#[derive(SessionDiagnostic)]
42+
#[diag(query_system::cycle, code = "E0391")]
43+
pub struct Cycle {
44+
#[primary_span]
45+
pub span: Span,
46+
pub stack_bottom: String,
47+
#[subdiagnostic]
48+
pub cycle_stack: Vec<CycleStack>,
49+
#[subdiagnostic]
50+
pub stack_count: StackCount,
51+
#[subdiagnostic]
52+
pub alias: Option<Alias>,
53+
#[subdiagnostic]
54+
pub cycle_usage: Option<CycleUsage>,
55+
}
56+
57+
#[derive(SessionDiagnostic)]
58+
#[diag(query_system::reentrant)]
59+
pub struct Reentrant;
60+
61+
#[derive(SessionDiagnostic)]
62+
#[diag(query_system::increment_compilation)]
63+
#[help]
64+
#[note(query_system::increment_compilation_note1)]
65+
#[note(query_system::increment_compilation_note2)]
66+
pub struct IncrementCompilation {
67+
pub run_cmd: String,
68+
pub dep_node: String,
69+
}
70+
71+
#[derive(SessionDiagnostic)]
72+
#[diag(query_system::query_overflow)]
73+
pub struct QueryOverflow;

‎compiler/rustc_query_system/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#![feature(min_specialization)]
66
#![feature(extern_types)]
77
#![allow(rustc::potential_query_instability)]
8+
// #![deny(rustc::untranslatable_diagnostic)]
9+
#![deny(rustc::diagnostic_outside_of_impl)]
810

911
#[macro_use]
1012
extern crate tracing;
@@ -15,5 +17,6 @@ extern crate rustc_macros;
1517

1618
pub mod cache;
1719
pub mod dep_graph;
20+
mod error;
1821
pub mod ich;
1922
pub mod query;

‎compiler/rustc_query_system/src/query/job.rs

+33-36
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1+
use crate::error::CycleStack;
12
use crate::query::plumbing::CycleError;
23
use crate::query::{QueryContext, QueryStackFrame};
3-
use rustc_hir::def::DefKind;
44

55
use rustc_data_structures::fx::FxHashMap;
6-
use rustc_errors::{
7-
struct_span_err, Diagnostic, DiagnosticBuilder, ErrorGuaranteed, Handler, Level,
8-
};
9-
use rustc_session::Session;
6+
use rustc_errors::{Diagnostic, DiagnosticBuilder, ErrorGuaranteed, Handler, Level};
7+
use rustc_hir::def::DefKind;
8+
use rustc_session::{Session, SessionDiagnostic};
109
use rustc_span::Span;
1110

1211
use std::hash::Hash;
@@ -536,46 +535,44 @@ pub(crate) fn report_cycle<'a>(
536535
assert!(!stack.is_empty());
537536

538537
let span = stack[0].query.default_span(stack[1 % stack.len()].span);
539-
let mut err =
540-
struct_span_err!(sess, span, E0391, "cycle detected when {}", stack[0].query.description);
538+
539+
let mut cycle_stack = Vec::new();
540+
541+
use crate::error::StackCount;
542+
let stack_count = if stack.len() == 1 { StackCount::Single } else { StackCount::Multiple };
541543

542544
for i in 1..stack.len() {
543545
let query = &stack[i].query;
544546
let span = query.default_span(stack[(i + 1) % stack.len()].span);
545-
err.span_note(span, &format!("...which requires {}...", query.description));
546-
}
547-
548-
if stack.len() == 1 {
549-
err.note(&format!("...which immediately requires {} again", stack[0].query.description));
550-
} else {
551-
err.note(&format!(
552-
"...which again requires {}, completing the cycle",
553-
stack[0].query.description
554-
));
555-
}
556-
557-
if stack.iter().all(|entry| {
558-
entry
559-
.query
560-
.def_kind
561-
.map_or(false, |def_kind| matches!(def_kind, DefKind::TyAlias | DefKind::TraitAlias))
562-
}) {
563-
if stack.iter().all(|entry| {
564-
entry.query.def_kind.map_or(false, |def_kind| matches!(def_kind, DefKind::TyAlias))
565-
}) {
566-
err.note("type aliases cannot be recursive");
567-
err.help("consider using a struct, enum, or union instead to break the cycle");
568-
err.help("see <https://doc.rust-lang.org/reference/types.html#recursive-types> for more information");
569-
} else {
570-
err.note("trait aliases cannot be recursive");
571-
}
547+
cycle_stack.push(CycleStack { span, desc: query.description.to_owned() });
572548
}
573549

550+
let mut cycle_usage = None;
574551
if let Some((span, query)) = usage {
575-
err.span_note(query.default_span(span), &format!("cycle used when {}", query.description));
552+
cycle_usage = Some(crate::error::CycleUsage {
553+
span: query.default_span(span),
554+
usage: query.description,
555+
});
576556
}
577557

578-
err
558+
let alias = if stack.iter().all(|entry| entry.query.def_kind == Some(DefKind::TyAlias)) {
559+
Some(crate::error::Alias::Ty)
560+
} else if stack.iter().all(|entry| entry.query.def_kind == Some(DefKind::TraitAlias)) {
561+
Some(crate::error::Alias::Trait)
562+
} else {
563+
None
564+
};
565+
566+
let cycle_diag = crate::error::Cycle {
567+
span,
568+
cycle_stack,
569+
stack_bottom: stack[0].query.description.to_owned(),
570+
alias,
571+
cycle_usage: cycle_usage,
572+
stack_count,
573+
};
574+
575+
cycle_diag.into_diagnostic(&sess.parse_sess)
579576
}
580577

581578
pub fn print_query_stack<CTX: QueryContext>(

‎compiler/rustc_query_system/src/query/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,6 @@ pub trait QueryContext: HasDepContext {
125125
) -> R;
126126

127127
fn depth_limit_error(&self) {
128-
self.dep_context().sess().fatal("queries overflow the depth limit!");
128+
self.dep_context().sess().emit_fatal(crate::error::QueryOverflow);
129129
}
130130
}

‎compiler/rustc_query_system/src/query/plumbing.rs

+5-9
Original file line numberDiff line numberDiff line change
@@ -618,16 +618,12 @@ fn incremental_verify_ich_cold(sess: &Session, dep_node: DebugArg<'_>, result: D
618618
let old_in_panic = INSIDE_VERIFY_PANIC.with(|in_panic| in_panic.replace(true));
619619

620620
if old_in_panic {
621-
sess.struct_err(
622-
"internal compiler error: re-entrant incremental verify failure, suppressing message",
623-
)
624-
.emit();
621+
sess.emit_err(crate::error::Reentrant);
625622
} else {
626-
sess.struct_err(&format!("internal compiler error: encountered incremental compilation error with {:?}", dep_node))
627-
.help(&format!("This is a known issue with the compiler. Run {} to allow your project to compile", run_cmd))
628-
.note("Please follow the instructions below to create a bug report with the provided information")
629-
.note("See <https://github.com/rust-lang/rust/issues/84970> for more information")
630-
.emit();
623+
sess.emit_err(crate::error::IncrementCompilation {
624+
run_cmd,
625+
dep_node: format!("{:?}", dep_node),
626+
});
631627
panic!("Found unstable fingerprints for {:?}: {:?}", dep_node, result);
632628
}
633629

‎src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs

+20-144
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ enum P {
167167
#[derive(SessionSubdiagnostic)]
168168
enum Q {
169169
#[bar]
170-
//~^ ERROR `#[bar]` is not a valid attribute
171-
//~^^ ERROR cannot find attribute `bar` in this scope
170+
//~^ ERROR `#[bar]` is not a valid attribute
171+
//~^^ ERROR cannot find attribute `bar` in this scope
172172
A {
173173
#[primary_span]
174174
span: Span,
@@ -179,8 +179,8 @@ enum Q {
179179
#[derive(SessionSubdiagnostic)]
180180
enum R {
181181
#[bar = "..."]
182-
//~^ ERROR `#[bar = ...]` is not a valid attribute
183-
//~^^ ERROR cannot find attribute `bar` in this scope
182+
//~^ ERROR `#[bar = ...]` is not a valid attribute
183+
//~^^ ERROR cannot find attribute `bar` in this scope
184184
A {
185185
#[primary_span]
186186
span: Span,
@@ -191,8 +191,8 @@ enum R {
191191
#[derive(SessionSubdiagnostic)]
192192
enum S {
193193
#[bar = 4]
194-
//~^ ERROR `#[bar = ...]` is not a valid attribute
195-
//~^^ ERROR cannot find attribute `bar` in this scope
194+
//~^ ERROR `#[bar = ...]` is not a valid attribute
195+
//~^^ ERROR cannot find attribute `bar` in this scope
196196
A {
197197
#[primary_span]
198198
span: Span,
@@ -203,8 +203,8 @@ enum S {
203203
#[derive(SessionSubdiagnostic)]
204204
enum T {
205205
#[bar("...")]
206-
//~^ ERROR `#[bar(...)]` is not a valid attribute
207-
//~^^ ERROR cannot find attribute `bar` in this scope
206+
//~^ ERROR `#[bar("...")]` is not a valid attribute
207+
//~^^ ERROR cannot find attribute `bar` in this scope
208208
A {
209209
#[primary_span]
210210
span: Span,
@@ -215,7 +215,7 @@ enum T {
215215
#[derive(SessionSubdiagnostic)]
216216
enum U {
217217
#[label(code = "...")]
218-
//~^ ERROR diagnostic slug must be first argument of a `#[label(...)]` attribute
218+
//~^ ERROR diagnostic slug must be first argument of a `#[label(...)]` attribute
219219
A {
220220
#[primary_span]
221221
span: Span,
@@ -232,7 +232,7 @@ enum V {
232232
var: String,
233233
},
234234
B {
235-
//~^ ERROR subdiagnostic kind not specified
235+
//~^ ERROR subdiagnostic kind not specified
236236
#[primary_span]
237237
span: Span,
238238
var: String,
@@ -307,16 +307,6 @@ union AC {
307307
b: u64
308308
}
309309

310-
#[derive(SessionSubdiagnostic)]
311-
#[label(parser::add_paren)]
312-
//~^ NOTE previously specified here
313-
#[label(parser::add_paren)]
314-
//~^ ERROR specified multiple times
315-
struct AD {
316-
#[primary_span]
317-
span: Span,
318-
}
319-
320310
#[derive(SessionSubdiagnostic)]
321311
#[label(parser::add_paren, parser::add_paren)]
322312
//~^ ERROR `#[label(parser::add_paren)]` is not a valid attribute
@@ -329,16 +319,16 @@ struct AE {
329319
#[label(parser::add_paren)]
330320
struct AF {
331321
#[primary_span]
332-
//~^ NOTE previously specified here
322+
//~^ NOTE previously specified here
333323
span_a: Span,
334324
#[primary_span]
335-
//~^ ERROR specified multiple times
325+
//~^ ERROR specified multiple times
336326
span_b: Span,
337327
}
338328

339329
#[derive(SessionSubdiagnostic)]
340330
struct AG {
341-
//~^ ERROR subdiagnostic kind not specified
331+
//~^ ERROR subdiagnostic kind not specified
342332
#[primary_span]
343333
span: Span,
344334
}
@@ -390,25 +380,27 @@ struct AK {
390380
#[primary_span]
391381
span: Span,
392382
#[applicability]
393-
//~^ NOTE previously specified here
383+
//~^ NOTE previously specified here
394384
applicability_a: Applicability,
395385
#[applicability]
396-
//~^ ERROR specified multiple times
386+
//~^ ERROR specified multiple times
397387
applicability_b: Applicability,
398388
}
399389

400390
#[derive(SessionSubdiagnostic)]
401391
#[suggestion(parser::add_paren, code = "...")]
392+
//~^ ERROR suggestion without `applicability`
402393
struct AL {
403394
#[primary_span]
404395
span: Span,
405396
#[applicability]
406-
//~^ ERROR the `#[applicability]` attribute can only be applied to fields of type `Applicability`
397+
//~^ ERROR the `#[applicability]` attribute can only be applied to fields of type `Applicability`
407398
applicability: Span,
408399
}
409400

410401
#[derive(SessionSubdiagnostic)]
411402
#[suggestion(parser::add_paren, code = "...")]
403+
//~^ ERROR suggestion without `applicability`
412404
struct AM {
413405
#[primary_span]
414406
span: Span,
@@ -444,7 +436,8 @@ struct AQ;
444436

445437
#[derive(SessionSubdiagnostic)]
446438
#[suggestion(parser::add_paren, code = "...")]
447-
//~^ ERROR suggestion without `#[primary_span]` field
439+
//~^ ERROR suggestion without `applicability`
440+
//~^^ ERROR suggestion without `#[primary_span]` field
448441
struct AR {
449442
var: String,
450443
}
@@ -514,120 +507,3 @@ struct AZ {
514507
#[primary_span]
515508
span: Span,
516509
}
517-
518-
#[derive(SessionSubdiagnostic)]
519-
#[suggestion(parser::add_paren, code = "...")]
520-
//~^ ERROR suggestion without `#[primary_span]` field
521-
struct BA {
522-
#[suggestion_part]
523-
//~^ ERROR `#[suggestion_part]` is not a valid attribute
524-
span: Span,
525-
#[suggestion_part(code = "...")]
526-
//~^ ERROR `#[suggestion_part(...)]` is not a valid attribute
527-
span2: Span,
528-
#[applicability]
529-
applicability: Applicability,
530-
var: String,
531-
}
532-
533-
#[derive(SessionSubdiagnostic)]
534-
#[multipart_suggestion(parser::add_paren, code = "...", applicability = "machine-applicable")]
535-
//~^ ERROR multipart suggestion without any `#[suggestion_part(...)]` fields
536-
//~| ERROR `code` is not a valid nested attribute of a `multipart_suggestion` attribute
537-
struct BBa {
538-
var: String,
539-
}
540-
541-
#[derive(SessionSubdiagnostic)]
542-
#[multipart_suggestion(parser::add_paren, applicability = "machine-applicable")]
543-
struct BBb {
544-
#[suggestion_part]
545-
//~^ ERROR `#[suggestion_part(...)]` attribute without `code = "..."`
546-
span1: Span,
547-
}
548-
549-
#[derive(SessionSubdiagnostic)]
550-
#[multipart_suggestion(parser::add_paren, applicability = "machine-applicable")]
551-
struct BBc {
552-
#[suggestion_part()]
553-
//~^ ERROR `#[suggestion_part(...)]` attribute without `code = "..."`
554-
span1: Span,
555-
}
556-
557-
#[derive(SessionSubdiagnostic)]
558-
#[multipart_suggestion(parser::add_paren)]
559-
//~^ ERROR multipart suggestion without any `#[suggestion_part(...)]` fields
560-
struct BC {
561-
#[primary_span]
562-
//~^ ERROR `#[primary_span]` is not a valid attribute
563-
span: Span,
564-
}
565-
566-
#[derive(SessionSubdiagnostic)]
567-
#[multipart_suggestion(parser::add_paren)]
568-
struct BD {
569-
#[suggestion_part]
570-
//~^ ERROR `#[suggestion_part(...)]` attribute without `code = "..."`
571-
span1: Span,
572-
#[suggestion_part()]
573-
//~^ ERROR `#[suggestion_part(...)]` attribute without `code = "..."`
574-
span2: Span,
575-
#[suggestion_part(foo = "bar")]
576-
//~^ ERROR `#[suggestion_part(foo = ...)]` is not a valid attribute
577-
span4: Span,
578-
#[suggestion_part(code = "...")]
579-
//~^ ERROR the `#[suggestion_part(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan`
580-
s1: String,
581-
#[suggestion_part()]
582-
//~^ ERROR the `#[suggestion_part(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan`
583-
s2: String,
584-
}
585-
586-
#[derive(SessionSubdiagnostic)]
587-
#[multipart_suggestion(parser::add_paren, applicability = "machine-applicable")]
588-
struct BE {
589-
#[suggestion_part(code = "...", code = ",,,")]
590-
//~^ ERROR specified multiple times
591-
//~| NOTE previously specified here
592-
span: Span,
593-
}
594-
595-
#[derive(SessionSubdiagnostic)]
596-
#[multipart_suggestion(parser::add_paren, applicability = "machine-applicable")]
597-
struct BF {
598-
#[suggestion_part(code = "(")]
599-
first: Span,
600-
#[suggestion_part(code = ")")]
601-
second: Span,
602-
}
603-
604-
#[derive(SessionSubdiagnostic)]
605-
#[multipart_suggestion(parser::add_paren)]
606-
struct BG {
607-
#[applicability]
608-
appl: Applicability,
609-
#[suggestion_part(code = "(")]
610-
first: Span,
611-
#[suggestion_part(code = ")")]
612-
second: Span,
613-
}
614-
615-
#[derive(SessionSubdiagnostic)]
616-
#[multipart_suggestion(parser::add_paren, applicability = "machine-applicable")]
617-
//~^ NOTE previously specified here
618-
struct BH {
619-
#[applicability]
620-
//~^ ERROR specified multiple times
621-
appl: Applicability,
622-
#[suggestion_part(code = "(")]
623-
first: Span,
624-
#[suggestion_part(code = ")")]
625-
second: Span,
626-
}
627-
628-
#[derive(SessionSubdiagnostic)]
629-
#[multipart_suggestion(parser::add_paren, applicability = "machine-applicable")]
630-
struct BI {
631-
#[suggestion_part(code = "")]
632-
spans: Vec<Span>,
633-
}

‎src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr

+65-169
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,16 @@ LL | #[label()]
6565
| ^^^^^^^^^^
6666

6767
error: `code` is not a valid nested attribute of a `label` attribute
68-
--> $DIR/subdiagnostic-derive.rs:137:28
68+
--> $DIR/subdiagnostic-derive.rs:137:1
6969
|
7070
LL | #[label(parser::add_paren, code = "...")]
71-
| ^^^^^^^^^^^^
71+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7272

7373
error: `applicability` is not a valid nested attribute of a `label` attribute
74-
--> $DIR/subdiagnostic-derive.rs:146:28
74+
--> $DIR/subdiagnostic-derive.rs:146:1
7575
|
7676
LL | #[label(parser::add_paren, applicability = "machine-applicable")]
77-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
77+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7878

7979
error: unsupported type attribute for subdiagnostic enum
8080
--> $DIR/subdiagnostic-derive.rs:155:1
@@ -100,11 +100,13 @@ error: `#[bar = ...]` is not a valid attribute
100100
LL | #[bar = 4]
101101
| ^^^^^^^^^^
102102

103-
error: `#[bar(...)]` is not a valid attribute
104-
--> $DIR/subdiagnostic-derive.rs:205:5
103+
error: `#[bar("...")]` is not a valid attribute
104+
--> $DIR/subdiagnostic-derive.rs:205:11
105105
|
106106
LL | #[bar("...")]
107-
| ^^^^^^^^^^^^^
107+
| ^^^^^
108+
|
109+
= help: first argument of the attribute should be the diagnostic slug
108110

109111
error: diagnostic slug must be first argument of a `#[label(...)]` attribute
110112
--> $DIR/subdiagnostic-derive.rs:217:5
@@ -161,8 +163,6 @@ error: `#[bar(...)]` is not a valid attribute
161163
|
162164
LL | #[bar("...")]
163165
| ^^^^^^^^^^^^^
164-
|
165-
= help: only `primary_span`, `applicability` and `skip_arg` are valid field attributes
166166

167167
error: unexpected unsupported untagged union
168168
--> $DIR/subdiagnostic-derive.rs:304:1
@@ -174,246 +174,142 @@ LL | | b: u64
174174
LL | | }
175175
| |_^
176176

177-
error: specified multiple times
178-
--> $DIR/subdiagnostic-derive.rs:313:1
179-
|
180-
LL | #[label(parser::add_paren)]
181-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
182-
|
183-
note: previously specified here
184-
--> $DIR/subdiagnostic-derive.rs:311:1
185-
|
186-
LL | #[label(parser::add_paren)]
187-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
188-
189177
error: `#[label(parser::add_paren)]` is not a valid attribute
190-
--> $DIR/subdiagnostic-derive.rs:321:28
178+
--> $DIR/subdiagnostic-derive.rs:311:28
191179
|
192180
LL | #[label(parser::add_paren, parser::add_paren)]
193181
| ^^^^^^^^^^^^^^^^^
194182
|
195183
= help: a diagnostic slug must be the first argument to the attribute
196184

197185
error: specified multiple times
198-
--> $DIR/subdiagnostic-derive.rs:334:5
186+
--> $DIR/subdiagnostic-derive.rs:324:5
199187
|
200188
LL | #[primary_span]
201189
| ^^^^^^^^^^^^^^^
202190
|
203191
note: previously specified here
204-
--> $DIR/subdiagnostic-derive.rs:331:5
192+
--> $DIR/subdiagnostic-derive.rs:321:5
205193
|
206194
LL | #[primary_span]
207195
| ^^^^^^^^^^^^^^^
208196

209197
error: subdiagnostic kind not specified
210-
--> $DIR/subdiagnostic-derive.rs:340:8
198+
--> $DIR/subdiagnostic-derive.rs:330:8
211199
|
212200
LL | struct AG {
213201
| ^^
214202

215203
error: specified multiple times
216-
--> $DIR/subdiagnostic-derive.rs:377:47
204+
--> $DIR/subdiagnostic-derive.rs:367:47
217205
|
218206
LL | #[suggestion(parser::add_paren, code = "...", code = "...")]
219207
| ^^^^^^^^^^^^
220208
|
221209
note: previously specified here
222-
--> $DIR/subdiagnostic-derive.rs:377:33
210+
--> $DIR/subdiagnostic-derive.rs:367:33
223211
|
224212
LL | #[suggestion(parser::add_paren, code = "...", code = "...")]
225213
| ^^^^^^^^^^^^
226214

227215
error: specified multiple times
228-
--> $DIR/subdiagnostic-derive.rs:395:5
216+
--> $DIR/subdiagnostic-derive.rs:385:5
229217
|
230218
LL | #[applicability]
231219
| ^^^^^^^^^^^^^^^^
232220
|
233221
note: previously specified here
234-
--> $DIR/subdiagnostic-derive.rs:392:5
222+
--> $DIR/subdiagnostic-derive.rs:382:5
235223
|
236224
LL | #[applicability]
237225
| ^^^^^^^^^^^^^^^^
238226

239227
error: the `#[applicability]` attribute can only be applied to fields of type `Applicability`
240-
--> $DIR/subdiagnostic-derive.rs:405:5
228+
--> $DIR/subdiagnostic-derive.rs:396:5
241229
|
242230
LL | #[applicability]
243231
| ^^^^^^^^^^^^^^^^
244232

245-
error: suggestion without `code = "..."`
246-
--> $DIR/subdiagnostic-derive.rs:418:1
247-
|
248-
LL | #[suggestion(parser::add_paren)]
249-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
250-
251-
error: invalid applicability
252-
--> $DIR/subdiagnostic-derive.rs:428:46
253-
|
254-
LL | #[suggestion(parser::add_paren, code ="...", applicability = "foo")]
255-
| ^^^^^^^^^^^^^^^^^^^^^
256-
257-
error: suggestion without `#[primary_span]` field
258-
--> $DIR/subdiagnostic-derive.rs:446:1
233+
error: suggestion without `applicability`
234+
--> $DIR/subdiagnostic-derive.rs:391:1
259235
|
260236
LL | / #[suggestion(parser::add_paren, code = "...")]
261237
LL | |
262-
LL | | struct AR {
263-
LL | | var: String,
238+
LL | | struct AL {
239+
LL | | #[primary_span]
240+
... |
241+
LL | | applicability: Span,
264242
LL | | }
265243
| |_^
266244

267-
error: unsupported type attribute for subdiagnostic enum
268-
--> $DIR/subdiagnostic-derive.rs:460:1
269-
|
270-
LL | #[label]
271-
| ^^^^^^^^
272-
273-
error: `var` doesn't refer to a field on this type
274-
--> $DIR/subdiagnostic-derive.rs:480:39
275-
|
276-
LL | #[suggestion(parser::add_paren, code ="{var}", applicability = "machine-applicable")]
277-
| ^^^^^^^
278-
279-
error: `var` doesn't refer to a field on this type
280-
--> $DIR/subdiagnostic-derive.rs:499:43
281-
|
282-
LL | #[suggestion(parser::add_paren, code ="{var}", applicability = "machine-applicable")]
283-
| ^^^^^^^
284-
285-
error: `#[suggestion_part]` is not a valid attribute
286-
--> $DIR/subdiagnostic-derive.rs:522:5
287-
|
288-
LL | #[suggestion_part]
289-
| ^^^^^^^^^^^^^^^^^^
290-
|
291-
= help: `#[suggestion_part(...)]` is only valid in multipart suggestions, use `#[primary_span]` instead
292-
293-
error: `#[suggestion_part(...)]` is not a valid attribute
294-
--> $DIR/subdiagnostic-derive.rs:525:5
245+
error: suggestion without `applicability`
246+
--> $DIR/subdiagnostic-derive.rs:402:1
295247
|
296-
LL | #[suggestion_part(code = "...")]
297-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
298-
|
299-
= help: `#[suggestion_part(...)]` is only valid in multipart suggestions
248+
LL | / #[suggestion(parser::add_paren, code = "...")]
249+
LL | |
250+
LL | | struct AM {
251+
LL | | #[primary_span]
252+
LL | | span: Span,
253+
LL | | }
254+
| |_^
300255

301-
error: suggestion without `#[primary_span]` field
302-
--> $DIR/subdiagnostic-derive.rs:519:1
256+
error: suggestion without `code = "..."`
257+
--> $DIR/subdiagnostic-derive.rs:410:1
303258
|
304-
LL | / #[suggestion(parser::add_paren, code = "...")]
259+
LL | / #[suggestion(parser::add_paren)]
305260
LL | |
306-
LL | | struct BA {
307-
LL | | #[suggestion_part]
261+
LL | | struct AN {
262+
LL | | #[primary_span]
308263
... |
309-
LL | | var: String,
264+
LL | | applicability: Applicability,
310265
LL | | }
311266
| |_^
312267

313-
error: `code` is not a valid nested attribute of a `multipart_suggestion` attribute
314-
--> $DIR/subdiagnostic-derive.rs:534:43
268+
error: invalid applicability
269+
--> $DIR/subdiagnostic-derive.rs:420:46
315270
|
316-
LL | #[multipart_suggestion(parser::add_paren, code = "...", applicability = "machine-applicable")]
317-
| ^^^^^^^^^^^^
271+
LL | #[suggestion(parser::add_paren, code ="...", applicability = "foo")]
272+
| ^^^^^^^^^^^^^^^^^^^^^
318273

319-
error: multipart suggestion without any `#[suggestion_part(...)]` fields
320-
--> $DIR/subdiagnostic-derive.rs:534:1
274+
error: suggestion without `applicability`
275+
--> $DIR/subdiagnostic-derive.rs:438:1
321276
|
322-
LL | / #[multipart_suggestion(parser::add_paren, code = "...", applicability = "machine-applicable")]
277+
LL | / #[suggestion(parser::add_paren, code = "...")]
323278
LL | |
324279
LL | |
325-
LL | | struct BBa {
280+
LL | | struct AR {
326281
LL | | var: String,
327282
LL | | }
328283
| |_^
329284

330-
error: `#[suggestion_part(...)]` attribute without `code = "..."`
331-
--> $DIR/subdiagnostic-derive.rs:544:5
332-
|
333-
LL | #[suggestion_part]
334-
| ^^^^^^^^^^^^^^^^^^
335-
336-
error: `#[suggestion_part(...)]` attribute without `code = "..."`
337-
--> $DIR/subdiagnostic-derive.rs:552:5
338-
|
339-
LL | #[suggestion_part()]
340-
| ^^^^^^^^^^^^^^^^^^^^
341-
342-
error: `#[primary_span]` is not a valid attribute
343-
--> $DIR/subdiagnostic-derive.rs:561:5
344-
|
345-
LL | #[primary_span]
346-
| ^^^^^^^^^^^^^^^
347-
|
348-
= help: multipart suggestions use one or more `#[suggestion_part]`s rather than one `#[primary_span]`
349-
350-
error: multipart suggestion without any `#[suggestion_part(...)]` fields
351-
--> $DIR/subdiagnostic-derive.rs:558:1
285+
error: suggestion without `#[primary_span]` field
286+
--> $DIR/subdiagnostic-derive.rs:438:1
352287
|
353-
LL | / #[multipart_suggestion(parser::add_paren)]
288+
LL | / #[suggestion(parser::add_paren, code = "...")]
354289
LL | |
355-
LL | | struct BC {
356-
LL | | #[primary_span]
357290
LL | |
358-
LL | | span: Span,
291+
LL | | struct AR {
292+
LL | | var: String,
359293
LL | | }
360294
| |_^
361295

362-
error: `#[suggestion_part(...)]` attribute without `code = "..."`
363-
--> $DIR/subdiagnostic-derive.rs:569:5
364-
|
365-
LL | #[suggestion_part]
366-
| ^^^^^^^^^^^^^^^^^^
367-
368-
error: `#[suggestion_part(...)]` attribute without `code = "..."`
369-
--> $DIR/subdiagnostic-derive.rs:572:5
370-
|
371-
LL | #[suggestion_part()]
372-
| ^^^^^^^^^^^^^^^^^^^^
373-
374-
error: `#[suggestion_part(foo = ...)]` is not a valid attribute
375-
--> $DIR/subdiagnostic-derive.rs:575:23
376-
|
377-
LL | #[suggestion_part(foo = "bar")]
378-
| ^^^^^^^^^^^
379-
|
380-
= help: `code` is the only valid nested attribute
381-
382-
error: the `#[suggestion_part(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan`
383-
--> $DIR/subdiagnostic-derive.rs:578:5
384-
|
385-
LL | #[suggestion_part(code = "...")]
386-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
387-
388-
error: the `#[suggestion_part(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan`
389-
--> $DIR/subdiagnostic-derive.rs:581:5
296+
error: unsupported type attribute for subdiagnostic enum
297+
--> $DIR/subdiagnostic-derive.rs:453:1
390298
|
391-
LL | #[suggestion_part()]
392-
| ^^^^^^^^^^^^^^^^^^^^
299+
LL | #[label]
300+
| ^^^^^^^^
393301

394-
error: specified multiple times
395-
--> $DIR/subdiagnostic-derive.rs:589:37
396-
|
397-
LL | #[suggestion_part(code = "...", code = ",,,")]
398-
| ^^^^^^^^^^^^
399-
|
400-
note: previously specified here
401-
--> $DIR/subdiagnostic-derive.rs:589:23
302+
error: `var` doesn't refer to a field on this type
303+
--> $DIR/subdiagnostic-derive.rs:473:39
402304
|
403-
LL | #[suggestion_part(code = "...", code = ",,,")]
404-
| ^^^^^^^^^^^^
305+
LL | #[suggestion(parser::add_paren, code ="{var}", applicability = "machine-applicable")]
306+
| ^^^^^^^
405307

406-
error: specified multiple times
407-
--> $DIR/subdiagnostic-derive.rs:619:5
408-
|
409-
LL | #[applicability]
410-
| ^^^^^^^^^^^^^^^^
411-
|
412-
note: previously specified here
413-
--> $DIR/subdiagnostic-derive.rs:616:43
308+
error: `var` doesn't refer to a field on this type
309+
--> $DIR/subdiagnostic-derive.rs:492:43
414310
|
415-
LL | #[multipart_suggestion(parser::add_paren, applicability = "machine-applicable")]
416-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
311+
LL | #[suggestion(parser::add_paren, code ="{var}", applicability = "machine-applicable")]
312+
| ^^^^^^^
417313

418314
error: cannot find attribute `foo` in this scope
419315
--> $DIR/subdiagnostic-derive.rs:63:3
@@ -475,6 +371,6 @@ error[E0425]: cannot find value `slug` in module `rustc_errors::fluent`
475371
LL | #[label(slug)]
476372
| ^^^^ not found in `rustc_errors::fluent`
477373

478-
error: aborting due to 64 previous errors
374+
error: aborting due to 50 previous errors
479375

480376
For more information about this error, try `rustc --explain E0425`.

0 commit comments

Comments
 (0)
Please sign in to comment.