Skip to content

Commit 191fac6

Browse files
committed
UPDATE - rename AddSubdiagnostic trait to AddToDiagnostic
1 parent 19b348f commit 191fac6

File tree

11 files changed

+23
-23
lines changed

11 files changed

+23
-23
lines changed

compiler/rustc_ast_lowering/src/errors.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc_errors::{fluent, AddSubdiagnostic, Applicability, Diagnostic, DiagnosticArgFromDisplay};
1+
use rustc_errors::{fluent, AddToDiagnostic, Applicability, Diagnostic, DiagnosticArgFromDisplay};
22
use rustc_macros::{DiagnosticHandler, SessionSubdiagnostic};
33
use rustc_span::{symbol::Ident, Span, Symbol};
44

@@ -18,7 +18,7 @@ pub struct UseAngleBrackets {
1818
pub close_param: Span,
1919
}
2020

21-
impl AddSubdiagnostic for UseAngleBrackets {
21+
impl AddToDiagnostic for UseAngleBrackets {
2222
fn add_to_diagnostic(self, diag: &mut Diagnostic) {
2323
diag.multipart_suggestion(
2424
fluent::ast_lowering::use_angle_brackets,
@@ -54,7 +54,7 @@ pub enum AssocTyParenthesesSub {
5454
NotEmpty { open_param: Span, close_param: Span },
5555
}
5656

57-
impl AddSubdiagnostic for AssocTyParenthesesSub {
57+
impl AddToDiagnostic for AssocTyParenthesesSub {
5858
fn add_to_diagnostic(self, diag: &mut Diagnostic) {
5959
match self {
6060
Self::Empty { parentheses_span } => diag.multipart_suggestion(

compiler/rustc_error_messages/locales/en-US/lint.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ lint_non_existant_doc_keyword = found non-existing keyword `{$keyword}` used in
5151
.help = only existing keywords are allowed in core/std
5252
5353
lint_diag_out_of_impl =
54-
diagnostics should only be created in `IntoDiagnostic`/`AddSubdiagnostic` impls
54+
diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls
5555
5656
lint_untranslatable_diag = diagnostics should be created using translatable messages
5757

compiler/rustc_errors/src/diagnostic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ impl IntoDiagnosticArg for hir::ConstContext {
178178
/// Trait implemented by error types. This should not be implemented manually. Instead, use
179179
/// `#[derive(SessionSubdiagnostic)]` -- see [rustc_macros::SessionSubdiagnostic].
180180
#[rustc_diagnostic_item = "AddSubdiagnostic"]
181-
pub trait AddSubdiagnostic {
181+
pub trait AddToDiagnostic {
182182
/// Add a subdiagnostic to an existing diagnostic.
183183
fn add_to_diagnostic(self, diag: &mut Diagnostic);
184184
}
@@ -893,7 +893,7 @@ impl Diagnostic {
893893

894894
/// Add a subdiagnostic from a type that implements `SessionSubdiagnostic` - see
895895
/// [rustc_macros::SessionSubdiagnostic].
896-
pub fn subdiagnostic(&mut self, subdiagnostic: impl AddSubdiagnostic) -> &mut Self {
896+
pub fn subdiagnostic(&mut self, subdiagnostic: impl AddToDiagnostic) -> &mut Self {
897897
subdiagnostic.add_to_diagnostic(self);
898898
self
899899
}

compiler/rustc_errors/src/diagnostic_builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
580580

581581
forward!(pub fn subdiagnostic(
582582
&mut self,
583-
subdiagnostic: impl crate::AddSubdiagnostic
583+
subdiagnostic: impl crate::AddToDiagnostic
584584
) -> &mut Self);
585585
}
586586

compiler/rustc_errors/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ impl fmt::Display for ExplicitBug {
371371
impl error::Error for ExplicitBug {}
372372

373373
pub use diagnostic::{
374-
AddSubdiagnostic, DecorateLint, Diagnostic, DiagnosticArg, DiagnosticArgFromDisplay,
374+
AddToDiagnostic, DecorateLint, Diagnostic, DiagnosticArg, DiagnosticArgFromDisplay,
375375
DiagnosticArgValue, DiagnosticId, DiagnosticStyledString, IntoDiagnosticArg, SubDiagnostic,
376376
};
377377
pub use diagnostic_builder::{DiagnosticBuilder, EmissionGuarantee, LintDiagnosticBuilder};

compiler/rustc_infer/src/infer/error_reporting/note.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::errors::RegionOriginNote;
22
use crate::infer::error_reporting::note_and_explain_region;
33
use crate::infer::{self, InferCtxt, SubregionOrigin};
44
use rustc_errors::{
5-
fluent, struct_span_err, AddSubdiagnostic, Diagnostic, DiagnosticBuilder, ErrorGuaranteed,
5+
fluent, struct_span_err, AddToDiagnostic, Diagnostic, DiagnosticBuilder, ErrorGuaranteed,
66
};
77
use rustc_middle::traits::ObligationCauseCode;
88
use rustc_middle::ty::error::TypeError;

compiler/rustc_lint/src/errors.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc_errors::{fluent, AddSubdiagnostic, IntoDiagnostic, ErrorGuaranteed, Handler};
1+
use rustc_errors::{fluent, AddToDiagnostic, IntoDiagnostic, ErrorGuaranteed, Handler};
22
use rustc_macros::{DiagnosticHandler, SessionSubdiagnostic};
33
use rustc_session::lint::Level;
44
use rustc_span::{Span, Symbol};
@@ -22,7 +22,7 @@ pub enum OverruledAttributeSub {
2222
CommandLineSource,
2323
}
2424

25-
impl AddSubdiagnostic for OverruledAttributeSub {
25+
impl AddToDiagnostic for OverruledAttributeSub {
2626
fn add_to_diagnostic(self, diag: &mut rustc_errors::Diagnostic) {
2727
match self {
2828
OverruledAttributeSub::DefaultSource { id } => {
@@ -87,7 +87,7 @@ pub struct RequestedLevel {
8787
pub lint_name: String,
8888
}
8989

90-
impl AddSubdiagnostic for RequestedLevel {
90+
impl AddToDiagnostic for RequestedLevel {
9191
fn add_to_diagnostic(self, diag: &mut rustc_errors::Diagnostic) {
9292
diag.note(fluent::lint::requested_level);
9393
diag.set_arg(

compiler/rustc_lint/src/internal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ declare_tool_lint! {
372372
declare_tool_lint! {
373373
pub rustc::DIAGNOSTIC_OUTSIDE_OF_IMPL,
374374
Allow,
375-
"prevent creation of diagnostics outside of `DiagnosticHandler`/`AddSubdiagnostic` impls",
375+
"prevent creation of diagnostics outside of `DiagnosticHandler`/`AddToDiagnostic` impls",
376376
report_in_external_macro: true
377377
}
378378

compiler/rustc_macros/src/diagnostics/subdiagnostic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ impl<'a> SessionSubdiagnosticDerive<'a> {
166166
};
167167

168168
let ret = structure.gen_impl(quote! {
169-
gen impl rustc_errors::AddSubdiagnostic for @Self {
169+
gen impl rustc_errors::AddToDiagnostic for @Self {
170170
fn add_to_diagnostic(self, #diag: &mut rustc_errors::Diagnostic) {
171171
use rustc_errors::{Applicability, IntoDiagnosticArg};
172172
#implementation

src/test/ui-fulldeps/internal-lints/diagnostics.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ extern crate rustc_session;
1212
extern crate rustc_span;
1313

1414
use rustc_errors::{
15-
AddSubdiagnostic, IntoDiagnostic, Diagnostic, DiagnosticBuilder,
15+
AddToDiagnostic, IntoDiagnostic, Diagnostic, DiagnosticBuilder,
1616
ErrorGuaranteed, Handler, fluent
1717
};
1818
use rustc_macros::{DiagnosticHandler, SessionSubdiagnostic};
@@ -49,29 +49,29 @@ impl<'a> IntoDiagnostic<'a, ErrorGuaranteed> for TranslatableInSessionDiagnostic
4949
}
5050
}
5151

52-
pub struct UntranslatableInAddSubdiagnostic;
52+
pub struct UntranslatableInAddToDiagnostic;
5353

54-
impl AddSubdiagnostic for UntranslatableInAddSubdiagnostic {
54+
impl AddToDiagnostic for UntranslatableInAddToDiagnostic {
5555
fn add_to_diagnostic(self, diag: &mut Diagnostic) {
5656
diag.note("untranslatable diagnostic");
5757
//~^ ERROR diagnostics should be created using translatable messages
5858
}
5959
}
6060

61-
pub struct TranslatableInAddSubdiagnostic;
61+
pub struct TranslatableInAddToDiagnostic;
6262

63-
impl AddSubdiagnostic for TranslatableInAddSubdiagnostic {
63+
impl AddToDiagnostic for TranslatableInAddToDiagnostic {
6464
fn add_to_diagnostic(self, diag: &mut Diagnostic) {
6565
diag.note(fluent::typeck::note);
6666
}
6767
}
6868

6969
pub fn make_diagnostics<'a>(handler: &'a Handler) {
7070
let _diag = handler.struct_err(fluent::parser::expect_path);
71-
//~^ ERROR diagnostics should only be created in `IntoDiagnostic`/`AddSubdiagnostic` impls
71+
//~^ ERROR diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls
7272

7373
let _diag = handler.struct_err("untranslatable diagnostic");
74-
//~^ ERROR diagnostics should only be created in `IntoDiagnostic`/`AddSubdiagnostic` impls
74+
//~^ ERROR diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls
7575
//~^^ ERROR diagnostics should be created using translatable messages
7676
}
7777

src/test/ui-fulldeps/internal-lints/diagnostics.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ error: diagnostics should be created using translatable messages
1616
LL | diag.note("untranslatable diagnostic");
1717
| ^^^^
1818

19-
error: diagnostics should only be created in `IntoDiagnostic`/`AddSubdiagnostic` impls
19+
error: diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls
2020
--> $DIR/diagnostics.rs:70:25
2121
|
2222
LL | let _diag = handler.struct_err(fluent::parser::expect_path);
@@ -28,7 +28,7 @@ note: the lint level is defined here
2828
LL | #![deny(rustc::diagnostic_outside_of_impl)]
2929
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3030

31-
error: diagnostics should only be created in `IntoDiagnostic`/`AddSubdiagnostic` impls
31+
error: diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls
3232
--> $DIR/diagnostics.rs:73:25
3333
|
3434
LL | let _diag = handler.struct_err("untranslatable diagnostic");

0 commit comments

Comments
 (0)