Skip to content

Commit 541d7cc

Browse files
committed
Rename AddToDiagnostic as Subdiagnostic.
To match `derive(Subdiagnostic)`. Also rename `add_to_diagnostic{,_with}` as `add_to_diag{,_with}`.
1 parent 7a294e9 commit 541d7cc

File tree

28 files changed

+153
-153
lines changed

28 files changed

+153
-153
lines changed

Diff for: compiler/rustc_ast_lowering/src/errors.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
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};
@@ -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,

Diff for: 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,

Diff for: compiler/rustc_builtin_macros/src/errors.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use rustc_errors::{
2-
codes::*, AddToDiagnostic, Diag, DiagCtxt, Diagnostic, EmissionGuarantee, 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};
@@ -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,

Diff for: compiler/rustc_errors/src/diagnostic.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -170,19 +170,19 @@ impl Into<FluentValue<'static>> for DiagArgValue {
170170

171171
/// Trait implemented by error types. This should not be implemented manually. Instead, use
172172
/// `#[derive(Subdiagnostic)]` -- see [rustc_macros::Subdiagnostic].
173-
#[rustc_diagnostic_item = "AddToDiagnostic"]
174-
pub trait AddToDiagnostic
173+
#[rustc_diagnostic_item = "Subdiagnostic"]
174+
pub trait Subdiagnostic
175175
where
176176
Self: Sized,
177177
{
178178
/// Add a subdiagnostic to an existing diagnostic.
179-
fn add_to_diagnostic<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
180-
self.add_to_diagnostic_with(diag, |_, m| m);
179+
fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
180+
self.add_to_diag_with(diag, |_, m| m);
181181
}
182182

183183
/// Add a subdiagnostic to an existing diagnostic where `f` is invoked on every message used
184184
/// (to optionally perform eager translation).
185-
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
185+
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
186186
self,
187187
diag: &mut Diag<'_, G>,
188188
f: F,
@@ -1194,9 +1194,9 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
11941194
pub fn subdiagnostic(
11951195
&mut self,
11961196
dcx: &crate::DiagCtxt,
1197-
subdiagnostic: impl AddToDiagnostic,
1197+
subdiagnostic: impl Subdiagnostic,
11981198
) -> &mut Self {
1199-
subdiagnostic.add_to_diagnostic_with(self, |diag, msg| {
1199+
subdiagnostic.add_to_diag_with(self, |diag, msg| {
12001200
let args = diag.args.iter();
12011201
let msg = diag.subdiagnostic_message_to_diagnostic_message(msg);
12021202
dcx.eagerly_translate(msg, args)

Diff for: compiler/rustc_errors/src/diagnostic_impls.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::diagnostic::DiagLocation;
2-
use crate::{fluent_generated as fluent, AddToDiagnostic};
2+
use crate::{fluent_generated as fluent, Subdiagnostic};
33
use crate::{
44
Diag, DiagArgValue, DiagCtxt, Diagnostic, EmissionGuarantee, ErrCode, IntoDiagArg, Level,
55
SubdiagMessageOp,
@@ -297,8 +297,8 @@ pub struct SingleLabelManySpans {
297297
pub spans: Vec<Span>,
298298
pub label: &'static str,
299299
}
300-
impl AddToDiagnostic for SingleLabelManySpans {
301-
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
300+
impl Subdiagnostic for SingleLabelManySpans {
301+
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
302302
self,
303303
diag: &mut Diag<'_, G>,
304304
_: F,

Diff for: compiler/rustc_errors/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ extern crate self as rustc_errors;
3737

3838
pub use codes::*;
3939
pub use diagnostic::{
40-
AddToDiagnostic, BugAbort, DecorateLint, Diag, DiagArg, DiagArgMap, DiagArgName, DiagArgValue,
41-
DiagInner, DiagStyledString, Diagnostic, EmissionGuarantee, FatalAbort, IntoDiagArg,
42-
StringPart, Subdiag, SubdiagMessageOp,
40+
BugAbort, DecorateLint, Diag, DiagArg, DiagArgMap, DiagArgName, DiagArgValue, DiagInner,
41+
DiagStyledString, Diagnostic, EmissionGuarantee, FatalAbort, IntoDiagArg, StringPart, Subdiag,
42+
SubdiagMessageOp, Subdiagnostic,
4343
};
4444
pub use diagnostic_impls::{
4545
DiagArgFromDisplay, DiagSymbolList, ExpectedLifetimeParameter, IndicateAnonymousLifetime,

Diff for: compiler/rustc_hir_typeck/src/errors.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use std::borrow::Cow;
33

44
use crate::fluent_generated as fluent;
55
use rustc_errors::{
6-
codes::*, AddToDiagnostic, Applicability, Diag, DiagArgValue, EmissionGuarantee, IntoDiagArg,
7-
MultiSpan, SubdiagMessageOp,
6+
codes::*, Applicability, Diag, DiagArgValue, EmissionGuarantee, IntoDiagArg, MultiSpan,
7+
SubdiagMessageOp, Subdiagnostic,
88
};
99
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
1010
use rustc_middle::ty::Ty;
@@ -194,8 +194,8 @@ pub struct TypeMismatchFruTypo {
194194
pub expr: Option<String>,
195195
}
196196

197-
impl AddToDiagnostic for TypeMismatchFruTypo {
198-
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
197+
impl Subdiagnostic for TypeMismatchFruTypo {
198+
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
199199
self,
200200
diag: &mut Diag<'_, G>,
201201
_f: F,
@@ -373,8 +373,8 @@ pub struct RemoveSemiForCoerce {
373373
pub semi: Span,
374374
}
375375

376-
impl AddToDiagnostic for RemoveSemiForCoerce {
377-
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
376+
impl Subdiagnostic for RemoveSemiForCoerce {
377+
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
378378
self,
379379
diag: &mut Diag<'_, G>,
380380
_f: F,
@@ -549,8 +549,8 @@ pub enum CastUnknownPointerSub {
549549
From(Span),
550550
}
551551

552-
impl rustc_errors::AddToDiagnostic for CastUnknownPointerSub {
553-
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
552+
impl rustc_errors::Subdiagnostic for CastUnknownPointerSub {
553+
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
554554
self,
555555
diag: &mut Diag<'_, G>,
556556
f: F,

Diff for: compiler/rustc_hir_typeck/src/expr.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
2626
use rustc_data_structures::stack::ensure_sufficient_stack;
2727
use rustc_data_structures::unord::UnordMap;
2828
use rustc_errors::{
29-
codes::*, pluralize, struct_span_code_err, AddToDiagnostic, Applicability, Diag,
30-
ErrorGuaranteed, StashKey,
29+
codes::*, pluralize, struct_span_code_err, Applicability, Diag, ErrorGuaranteed, StashKey,
30+
Subdiagnostic,
3131
};
3232
use rustc_hir as hir;
3333
use rustc_hir::def::{CtorKind, DefKind, Res};
@@ -2600,7 +2600,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
26002600
// We know by construction that `<expr>.await` is either on Rust 2015
26012601
// or results in `ExprKind::Await`. Suggest switching the edition to 2018.
26022602
err.note("to `.await` a `Future`, switch to Rust 2018 or later");
2603-
HelpUseLatestEdition::new().add_to_diagnostic(&mut err);
2603+
HelpUseLatestEdition::new().add_to_diag(&mut err);
26042604
}
26052605

26062606
err.emit()

Diff for: compiler/rustc_infer/src/errors/mod.rs

+20-20
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use hir::GenericParamKind;
22
use rustc_errors::{
3-
codes::*, AddToDiagnostic, Applicability, Diag, DiagMessage, DiagStyledString,
4-
EmissionGuarantee, IntoDiagArg, MultiSpan, SubdiagMessageOp,
3+
codes::*, Applicability, Diag, DiagMessage, DiagStyledString, EmissionGuarantee, IntoDiagArg,
4+
MultiSpan, SubdiagMessageOp, Subdiagnostic,
55
};
66
use rustc_hir as hir;
77
use rustc_hir::FnRetTy;
@@ -224,8 +224,8 @@ pub enum RegionOriginNote<'a> {
224224
},
225225
}
226226

227-
impl AddToDiagnostic for RegionOriginNote<'_> {
228-
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
227+
impl Subdiagnostic for RegionOriginNote<'_> {
228+
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
229229
self,
230230
diag: &mut Diag<'_, G>,
231231
_f: F,
@@ -289,8 +289,8 @@ pub enum LifetimeMismatchLabels {
289289
},
290290
}
291291

292-
impl AddToDiagnostic for LifetimeMismatchLabels {
293-
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
292+
impl Subdiagnostic for LifetimeMismatchLabels {
293+
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
294294
self,
295295
diag: &mut Diag<'_, G>,
296296
_f: F,
@@ -337,8 +337,8 @@ pub struct AddLifetimeParamsSuggestion<'a> {
337337
pub add_note: bool,
338338
}
339339

340-
impl AddToDiagnostic for AddLifetimeParamsSuggestion<'_> {
341-
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
340+
impl Subdiagnostic for AddLifetimeParamsSuggestion<'_> {
341+
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
342342
self,
343343
diag: &mut Diag<'_, G>,
344344
_f: F,
@@ -439,8 +439,8 @@ pub struct IntroducesStaticBecauseUnmetLifetimeReq {
439439
pub binding_span: Span,
440440
}
441441

442-
impl AddToDiagnostic for IntroducesStaticBecauseUnmetLifetimeReq {
443-
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
442+
impl Subdiagnostic for IntroducesStaticBecauseUnmetLifetimeReq {
443+
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
444444
mut self,
445445
diag: &mut Diag<'_, G>,
446446
_f: F,
@@ -758,8 +758,8 @@ pub struct ConsiderBorrowingParamHelp {
758758
pub spans: Vec<Span>,
759759
}
760760

761-
impl AddToDiagnostic for ConsiderBorrowingParamHelp {
762-
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
761+
impl Subdiagnostic for ConsiderBorrowingParamHelp {
762+
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
763763
self,
764764
diag: &mut Diag<'_, G>,
765765
f: F,
@@ -803,8 +803,8 @@ pub struct DynTraitConstraintSuggestion {
803803
pub ident: Ident,
804804
}
805805

806-
impl AddToDiagnostic for DynTraitConstraintSuggestion {
807-
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
806+
impl Subdiagnostic for DynTraitConstraintSuggestion {
807+
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
808808
self,
809809
diag: &mut Diag<'_, G>,
810810
f: F,
@@ -850,8 +850,8 @@ pub struct ReqIntroducedLocations {
850850
pub add_label: bool,
851851
}
852852

853-
impl AddToDiagnostic for ReqIntroducedLocations {
854-
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
853+
impl Subdiagnostic for ReqIntroducedLocations {
854+
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
855855
mut self,
856856
diag: &mut Diag<'_, G>,
857857
f: F,
@@ -873,8 +873,8 @@ pub struct MoreTargeted {
873873
pub ident: Symbol,
874874
}
875875

876-
impl AddToDiagnostic for MoreTargeted {
877-
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
876+
impl Subdiagnostic for MoreTargeted {
877+
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
878878
self,
879879
diag: &mut Diag<'_, G>,
880880
_f: F,
@@ -1296,8 +1296,8 @@ pub struct SuggestTuplePatternMany {
12961296
pub compatible_variants: Vec<String>,
12971297
}
12981298

1299-
impl AddToDiagnostic for SuggestTuplePatternMany {
1300-
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
1299+
impl Subdiagnostic for SuggestTuplePatternMany {
1300+
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
13011301
self,
13021302
diag: &mut Diag<'_, G>,
13031303
f: F,

Diff for: compiler/rustc_infer/src/errors/note_and_explain.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::fluent_generated as fluent;
22
use crate::infer::error_reporting::nice_region_error::find_anon_type;
3-
use rustc_errors::{AddToDiagnostic, Diag, EmissionGuarantee, IntoDiagArg, SubdiagMessageOp};
3+
use rustc_errors::{Diag, EmissionGuarantee, IntoDiagArg, SubdiagMessageOp, Subdiagnostic};
44
use rustc_middle::ty::{self, TyCtxt};
55
use rustc_span::{symbol::kw, Span};
66

@@ -159,8 +159,8 @@ impl RegionExplanation<'_> {
159159
}
160160
}
161161

162-
impl AddToDiagnostic for RegionExplanation<'_> {
163-
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
162+
impl Subdiagnostic for RegionExplanation<'_> {
163+
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
164164
self,
165165
diag: &mut Diag<'_, G>,
166166
f: F,

Diff for: compiler/rustc_infer/src/infer/error_reporting/nice_region_error/different_lifetimes.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::infer::lexical_region_resolve::RegionResolutionError;
1111
use crate::infer::SubregionOrigin;
1212
use crate::infer::TyCtxt;
1313

14-
use rustc_errors::AddToDiagnostic;
14+
use rustc_errors::Subdiagnostic;
1515
use rustc_errors::{Diag, ErrorGuaranteed};
1616
use rustc_hir::Ty;
1717
use rustc_middle::ty::Region;
@@ -145,5 +145,5 @@ pub fn suggest_adding_lifetime_params<'tcx>(
145145
err: &mut Diag<'_>,
146146
) {
147147
let suggestion = AddLifetimeParamsSuggestion { tcx, sub, ty_sup, ty_sub, add_note: false };
148-
suggestion.add_to_diagnostic(err);
148+
suggestion.add_to_diag(err);
149149
}

Diff for: compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::infer::lexical_region_resolve::RegionResolutionError;
99
use crate::infer::{SubregionOrigin, TypeTrace};
1010
use crate::traits::{ObligationCauseCode, UnifyReceiverContext};
1111
use rustc_data_structures::fx::FxIndexSet;
12-
use rustc_errors::{AddToDiagnostic, Applicability, Diag, ErrorGuaranteed, MultiSpan};
12+
use rustc_errors::{Applicability, Diag, ErrorGuaranteed, MultiSpan, Subdiagnostic};
1313
use rustc_hir::def_id::DefId;
1414
use rustc_hir::intravisit::{walk_ty, Visitor};
1515
use rustc_hir::{
@@ -234,7 +234,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
234234
if let (Some(ident), true) = (override_error_code, fn_returns.is_empty()) {
235235
// Provide a more targeted error code and description.
236236
let retarget_subdiag = MoreTargeted { ident };
237-
retarget_subdiag.add_to_diagnostic(&mut err);
237+
retarget_subdiag.add_to_diag(&mut err);
238238
}
239239

240240
let arg = match param.param.pat.simple_ident() {
@@ -532,7 +532,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
532532
hir_v.visit_ty(self_ty);
533533
for &span in &traits {
534534
let subdiag = DynTraitConstraintSuggestion { span, ident };
535-
subdiag.add_to_diagnostic(err);
535+
subdiag.add_to_diag(err);
536536
suggested = true;
537537
}
538538
}

0 commit comments

Comments
 (0)