Skip to content

Commit cd81f5b

Browse files
committed
Auto merge of rust-lang#122132 - nnethercote:diag-renaming3, r=nnethercote
Diagnostic renaming 3 A sequel to rust-lang#121780. r? `@davidtwco`
2 parents 76ee6fc + 43c0633 commit cd81f5b

File tree

78 files changed

+567
-586
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+567
-586
lines changed

compiler/rustc_ast_lowering/src/errors.rs

+31-31
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use rustc_errors::{
2-
codes::*, AddToDiagnostic, Diag, DiagArgFromDisplay, EmissionGuarantee, SubdiagMessageOp,
2+
codes::*, Diag, DiagArgFromDisplay, EmissionGuarantee, SubdiagMessageOp, Subdiagnostic,
33
};
44
use rustc_macros::{Diagnostic, Subdiagnostic};
55
use rustc_span::{symbol::Ident, Span, Symbol};
66

7-
#[derive(Diagnostic, Clone, Copy)]
7+
#[derive(Diagnostic)]
88
#[diag(ast_lowering_generic_type_with_parentheses, code = E0214)]
99
pub struct GenericTypeWithParentheses {
1010
#[primary_span]
@@ -14,7 +14,7 @@ pub struct GenericTypeWithParentheses {
1414
pub sub: Option<UseAngleBrackets>,
1515
}
1616

17-
#[derive(Clone, Copy, Subdiagnostic)]
17+
#[derive(Subdiagnostic)]
1818
#[multipart_suggestion(ast_lowering_use_angle_brackets, applicability = "maybe-incorrect")]
1919
pub struct UseAngleBrackets {
2020
#[suggestion_part(code = "<")]
@@ -40,8 +40,8 @@ pub struct InvalidAbi {
4040

4141
pub struct InvalidAbiReason(pub &'static str);
4242

43-
impl AddToDiagnostic for InvalidAbiReason {
44-
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
43+
impl Subdiagnostic for InvalidAbiReason {
44+
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
4545
self,
4646
diag: &mut Diag<'_, G>,
4747
_: F,
@@ -63,7 +63,7 @@ pub struct InvalidAbiSuggestion {
6363
pub suggestion: String,
6464
}
6565

66-
#[derive(Diagnostic, Clone, Copy)]
66+
#[derive(Diagnostic)]
6767
#[diag(ast_lowering_assoc_ty_parentheses)]
6868
pub struct AssocTyParentheses {
6969
#[primary_span]
@@ -72,7 +72,7 @@ pub struct AssocTyParentheses {
7272
pub sub: AssocTyParenthesesSub,
7373
}
7474

75-
#[derive(Clone, Copy, Subdiagnostic)]
75+
#[derive(Subdiagnostic)]
7676
pub enum AssocTyParenthesesSub {
7777
#[multipart_suggestion(ast_lowering_remove_parentheses)]
7878
Empty {
@@ -106,23 +106,23 @@ pub struct MisplacedAssocTyBinding {
106106
pub suggestion: Option<Span>,
107107
}
108108

109-
#[derive(Diagnostic, Clone, Copy)]
109+
#[derive(Diagnostic)]
110110
#[diag(ast_lowering_underscore_expr_lhs_assign)]
111111
pub struct UnderscoreExprLhsAssign {
112112
#[primary_span]
113113
#[label]
114114
pub span: Span,
115115
}
116116

117-
#[derive(Diagnostic, Clone, Copy)]
117+
#[derive(Diagnostic)]
118118
#[diag(ast_lowering_base_expression_double_dot, code = E0797)]
119119
pub struct BaseExpressionDoubleDot {
120120
#[primary_span]
121121
#[suggestion(code = "/* expr */", applicability = "has-placeholders", style = "verbose")]
122122
pub span: Span,
123123
}
124124

125-
#[derive(Diagnostic, Clone, Copy)]
125+
#[derive(Diagnostic)]
126126
#[diag(ast_lowering_await_only_in_async_fn_and_blocks, code = E0728)]
127127
pub struct AwaitOnlyInAsyncFnAndBlocks {
128128
#[primary_span]
@@ -132,50 +132,50 @@ pub struct AwaitOnlyInAsyncFnAndBlocks {
132132
pub item_span: Option<Span>,
133133
}
134134

135-
#[derive(Diagnostic, Clone, Copy)]
135+
#[derive(Diagnostic)]
136136
#[diag(ast_lowering_coroutine_too_many_parameters, code = E0628)]
137137
pub struct CoroutineTooManyParameters {
138138
#[primary_span]
139139
pub fn_decl_span: Span,
140140
}
141141

142-
#[derive(Diagnostic, Clone, Copy)]
142+
#[derive(Diagnostic)]
143143
#[diag(ast_lowering_closure_cannot_be_static, code = E0697)]
144144
pub struct ClosureCannotBeStatic {
145145
#[primary_span]
146146
pub fn_decl_span: Span,
147147
}
148148

149-
#[derive(Diagnostic, Clone, Copy)]
149+
#[derive(Diagnostic)]
150150
#[diag(ast_lowering_functional_record_update_destructuring_assignment)]
151151
pub struct FunctionalRecordUpdateDestructuringAssignment {
152152
#[primary_span]
153153
#[suggestion(code = "", applicability = "machine-applicable")]
154154
pub span: Span,
155155
}
156156

157-
#[derive(Diagnostic, Clone, Copy)]
157+
#[derive(Diagnostic)]
158158
#[diag(ast_lowering_async_coroutines_not_supported, code = E0727)]
159159
pub struct AsyncCoroutinesNotSupported {
160160
#[primary_span]
161161
pub span: Span,
162162
}
163163

164-
#[derive(Diagnostic, Clone, Copy)]
164+
#[derive(Diagnostic)]
165165
#[diag(ast_lowering_inline_asm_unsupported_target, code = E0472)]
166166
pub struct InlineAsmUnsupportedTarget {
167167
#[primary_span]
168168
pub span: Span,
169169
}
170170

171-
#[derive(Diagnostic, Clone, Copy)]
171+
#[derive(Diagnostic)]
172172
#[diag(ast_lowering_att_syntax_only_x86)]
173173
pub struct AttSyntaxOnlyX86 {
174174
#[primary_span]
175175
pub span: Span,
176176
}
177177

178-
#[derive(Diagnostic, Clone, Copy)]
178+
#[derive(Diagnostic)]
179179
#[diag(ast_lowering_abi_specified_multiple_times)]
180180
pub struct AbiSpecifiedMultipleTimes {
181181
#[primary_span]
@@ -187,7 +187,7 @@ pub struct AbiSpecifiedMultipleTimes {
187187
pub equivalent: Option<()>,
188188
}
189189

190-
#[derive(Diagnostic, Clone, Copy)]
190+
#[derive(Diagnostic)]
191191
#[diag(ast_lowering_clobber_abi_not_supported)]
192192
pub struct ClobberAbiNotSupported {
193193
#[primary_span]
@@ -203,7 +203,7 @@ pub struct InvalidAbiClobberAbi {
203203
pub supported_abis: String,
204204
}
205205

206-
#[derive(Diagnostic, Clone, Copy)]
206+
#[derive(Diagnostic)]
207207
#[diag(ast_lowering_invalid_register)]
208208
pub struct InvalidRegister<'a> {
209209
#[primary_span]
@@ -212,7 +212,7 @@ pub struct InvalidRegister<'a> {
212212
pub error: &'a str,
213213
}
214214

215-
#[derive(Diagnostic, Clone, Copy)]
215+
#[derive(Diagnostic)]
216216
#[diag(ast_lowering_invalid_register_class)]
217217
pub struct InvalidRegisterClass<'a> {
218218
#[primary_span]
@@ -241,7 +241,7 @@ pub enum InvalidAsmTemplateModifierRegClassSub {
241241
DoesNotSupportModifier { class_name: Symbol },
242242
}
243243

244-
#[derive(Diagnostic, Clone, Copy)]
244+
#[derive(Diagnostic)]
245245
#[diag(ast_lowering_invalid_asm_template_modifier_const)]
246246
pub struct InvalidAsmTemplateModifierConst {
247247
#[primary_span]
@@ -251,7 +251,7 @@ pub struct InvalidAsmTemplateModifierConst {
251251
pub op_span: Span,
252252
}
253253

254-
#[derive(Diagnostic, Clone, Copy)]
254+
#[derive(Diagnostic)]
255255
#[diag(ast_lowering_invalid_asm_template_modifier_sym)]
256256
pub struct InvalidAsmTemplateModifierSym {
257257
#[primary_span]
@@ -261,7 +261,7 @@ pub struct InvalidAsmTemplateModifierSym {
261261
pub op_span: Span,
262262
}
263263

264-
#[derive(Diagnostic, Clone, Copy)]
264+
#[derive(Diagnostic)]
265265
#[diag(ast_lowering_invalid_asm_template_modifier_label)]
266266
pub struct InvalidAsmTemplateModifierLabel {
267267
#[primary_span]
@@ -271,15 +271,15 @@ pub struct InvalidAsmTemplateModifierLabel {
271271
pub op_span: Span,
272272
}
273273

274-
#[derive(Diagnostic, Clone, Copy)]
274+
#[derive(Diagnostic)]
275275
#[diag(ast_lowering_register_class_only_clobber)]
276276
pub struct RegisterClassOnlyClobber {
277277
#[primary_span]
278278
pub op_span: Span,
279279
pub reg_class_name: Symbol,
280280
}
281281

282-
#[derive(Diagnostic, Clone, Copy)]
282+
#[derive(Diagnostic)]
283283
#[diag(ast_lowering_register_conflict)]
284284
pub struct RegisterConflict<'a> {
285285
#[primary_span]
@@ -293,7 +293,7 @@ pub struct RegisterConflict<'a> {
293293
pub in_out: Option<Span>,
294294
}
295295

296-
#[derive(Diagnostic, Clone, Copy)]
296+
#[derive(Diagnostic)]
297297
#[help]
298298
#[diag(ast_lowering_sub_tuple_binding)]
299299
pub struct SubTupleBinding<'a> {
@@ -311,7 +311,7 @@ pub struct SubTupleBinding<'a> {
311311
pub ctx: &'a str,
312312
}
313313

314-
#[derive(Diagnostic, Clone, Copy)]
314+
#[derive(Diagnostic)]
315315
#[diag(ast_lowering_extra_double_dot)]
316316
pub struct ExtraDoubleDot<'a> {
317317
#[primary_span]
@@ -322,15 +322,15 @@ pub struct ExtraDoubleDot<'a> {
322322
pub ctx: &'a str,
323323
}
324324

325-
#[derive(Diagnostic, Clone, Copy)]
325+
#[derive(Diagnostic)]
326326
#[note]
327327
#[diag(ast_lowering_misplaced_double_dot)]
328328
pub struct MisplacedDoubleDot {
329329
#[primary_span]
330330
pub span: Span,
331331
}
332332

333-
#[derive(Diagnostic, Clone, Copy)]
333+
#[derive(Diagnostic)]
334334
#[diag(ast_lowering_misplaced_relax_trait_bound)]
335335
pub struct MisplacedRelaxTraitBound {
336336
#[primary_span]
@@ -363,14 +363,14 @@ pub struct NeverPatternWithGuard {
363363
pub span: Span,
364364
}
365365

366-
#[derive(Diagnostic, Clone, Copy)]
366+
#[derive(Diagnostic)]
367367
#[diag(ast_lowering_arbitrary_expression_in_pattern)]
368368
pub struct ArbitraryExpressionInPattern {
369369
#[primary_span]
370370
pub span: Span,
371371
}
372372

373-
#[derive(Diagnostic, Clone, Copy)]
373+
#[derive(Diagnostic)]
374374
#[diag(ast_lowering_inclusive_range_with_no_end)]
375375
pub struct InclusiveRangeWithNoEnd {
376376
#[primary_span]

compiler/rustc_ast_passes/src/errors.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use rustc_ast::ParamKindOrd;
44
use rustc_errors::{
5-
codes::*, AddToDiagnostic, Applicability, Diag, EmissionGuarantee, SubdiagMessageOp,
5+
codes::*, Applicability, Diag, EmissionGuarantee, SubdiagMessageOp, Subdiagnostic,
66
};
77
use rustc_macros::{Diagnostic, Subdiagnostic};
88
use rustc_span::{symbol::Ident, Span, Symbol};
@@ -373,8 +373,8 @@ pub struct ArgsBeforeConstraint {
373373
pub struct EmptyLabelManySpans(pub Vec<Span>);
374374

375375
// The derive for `Vec<Span>` does multiple calls to `span_label`, adding commas between each
376-
impl AddToDiagnostic for EmptyLabelManySpans {
377-
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
376+
impl Subdiagnostic for EmptyLabelManySpans {
377+
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
378378
self,
379379
diag: &mut Diag<'_, G>,
380380
_: F,
@@ -742,8 +742,8 @@ pub struct StableFeature {
742742
pub since: Symbol,
743743
}
744744

745-
impl AddToDiagnostic for StableFeature {
746-
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
745+
impl Subdiagnostic for StableFeature {
746+
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
747747
self,
748748
diag: &mut Diag<'_, G>,
749749
_: F,

compiler/rustc_attr/src/session_diagnostics.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
use std::num::IntErrorKind;
22

33
use rustc_ast as ast;
4-
use rustc_errors::{
5-
codes::*, Applicability, Diag, DiagCtxt, EmissionGuarantee, IntoDiagnostic, Level,
6-
};
4+
use rustc_errors::{codes::*, Applicability, Diag, DiagCtxt, Diagnostic, EmissionGuarantee, Level};
75
use rustc_macros::Diagnostic;
86
use rustc_span::{Span, Symbol};
97

@@ -50,8 +48,8 @@ pub(crate) struct UnknownMetaItem<'a> {
5048
}
5149

5250
// Manual implementation to be able to format `expected` items correctly.
53-
impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for UnknownMetaItem<'_> {
54-
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> {
51+
impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for UnknownMetaItem<'_> {
52+
fn into_diag(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> {
5553
let expected = self.expected.iter().map(|name| format!("`{name}`")).collect::<Vec<_>>();
5654
Diag::new(dcx, level, fluent::attr_unknown_meta_item)
5755
.with_span(self.span)
@@ -203,8 +201,8 @@ pub(crate) struct UnsupportedLiteral {
203201
pub start_point_span: Span,
204202
}
205203

206-
impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for UnsupportedLiteral {
207-
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> {
204+
impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for UnsupportedLiteral {
205+
fn into_diag(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> {
208206
let mut diag = Diag::new(
209207
dcx,
210208
level,

compiler/rustc_borrowck/src/diagnostics/region_name.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,9 @@ impl Display for RegionName {
191191
}
192192
}
193193

194-
impl rustc_errors::IntoDiagnosticArg for RegionName {
195-
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
196-
self.to_string().into_diagnostic_arg()
194+
impl rustc_errors::IntoDiagArg for RegionName {
195+
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
196+
self.to_string().into_diag_arg()
197197
}
198198
}
199199

compiler/rustc_builtin_macros/src/errors.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use rustc_errors::{
2-
codes::*, AddToDiagnostic, Diag, DiagCtxt, EmissionGuarantee, IntoDiagnostic, Level, MultiSpan,
3-
SingleLabelManySpans, SubdiagMessageOp,
2+
codes::*, Diag, DiagCtxt, Diagnostic, EmissionGuarantee, Level, MultiSpan,
3+
SingleLabelManySpans, SubdiagMessageOp, Subdiagnostic,
44
};
55
use rustc_macros::{Diagnostic, Subdiagnostic};
66
use rustc_span::{symbol::Ident, Span, Symbol};
@@ -425,9 +425,9 @@ pub(crate) struct EnvNotDefinedWithUserMessage {
425425
}
426426

427427
// Hand-written implementation to support custom user messages.
428-
impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for EnvNotDefinedWithUserMessage {
428+
impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for EnvNotDefinedWithUserMessage {
429429
#[track_caller]
430-
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> {
430+
fn into_diag(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> {
431431
#[expect(
432432
rustc::untranslatable_diagnostic,
433433
reason = "cannot translate user-provided messages"
@@ -589,8 +589,8 @@ pub(crate) struct FormatUnusedArg {
589589

590590
// Allow the singular form to be a subdiagnostic of the multiple-unused
591591
// form of diagnostic.
592-
impl AddToDiagnostic for FormatUnusedArg {
593-
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
592+
impl Subdiagnostic for FormatUnusedArg {
593+
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
594594
self,
595595
diag: &mut Diag<'_, G>,
596596
f: F,
@@ -785,8 +785,8 @@ pub(crate) struct AsmClobberNoReg {
785785
pub(crate) clobbers: Vec<Span>,
786786
}
787787

788-
impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for AsmClobberNoReg {
789-
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> {
788+
impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for AsmClobberNoReg {
789+
fn into_diag(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> {
790790
// eager translation as `span_labels` takes `AsRef<str>`
791791
let lbl1 = dcx.eagerly_translate_to_string(
792792
crate::fluent_generated::builtin_macros_asm_clobber_abi,

compiler/rustc_codegen_gcc/src/errors.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc_errors::{Diag, DiagCtxt, EmissionGuarantee, IntoDiagnostic, Level};
1+
use rustc_errors::{Diag, DiagCtxt, Diagnostic, EmissionGuarantee, Level};
22
use rustc_macros::{Diagnostic, Subdiagnostic};
33
use rustc_span::Span;
44

@@ -89,8 +89,8 @@ pub(crate) struct TargetFeatureDisableOrEnable<'a> {
8989
#[help(codegen_gcc_missing_features)]
9090
pub(crate) struct MissingFeatures;
9191

92-
impl<G: EmissionGuarantee> IntoDiagnostic<'_, G> for TargetFeatureDisableOrEnable<'_> {
93-
fn into_diagnostic(self, dcx: &'_ DiagCtxt, level: Level) -> Diag<'_, G> {
92+
impl<G: EmissionGuarantee> Diagnostic<'_, G> for TargetFeatureDisableOrEnable<'_> {
93+
fn into_diag(self, dcx: &'_ DiagCtxt, level: Level) -> Diag<'_, G> {
9494
let mut diag = Diag::new(dcx, level, fluent::codegen_gcc_target_feature_disable_or_enable);
9595
if let Some(span) = self.span {
9696
diag.span(span);

0 commit comments

Comments
 (0)