UPDATE - rename AddSubdiagnostic trait to AddToDiagnostic

This commit is contained in:
Jhonny Bill Mena 2022-09-18 11:46:16 -04:00
parent 19b348fed4
commit 191fac6826
11 changed files with 23 additions and 23 deletions

View File

@ -1,4 +1,4 @@
use rustc_errors::{fluent, AddSubdiagnostic, Applicability, Diagnostic, DiagnosticArgFromDisplay};
use rustc_errors::{fluent, AddToDiagnostic, Applicability, Diagnostic, DiagnosticArgFromDisplay};
use rustc_macros::{DiagnosticHandler, SessionSubdiagnostic};
use rustc_span::{symbol::Ident, Span, Symbol};
@ -18,7 +18,7 @@ pub struct UseAngleBrackets {
pub close_param: Span,
}
impl AddSubdiagnostic for UseAngleBrackets {
impl AddToDiagnostic for UseAngleBrackets {
fn add_to_diagnostic(self, diag: &mut Diagnostic) {
diag.multipart_suggestion(
fluent::ast_lowering::use_angle_brackets,
@ -54,7 +54,7 @@ pub enum AssocTyParenthesesSub {
NotEmpty { open_param: Span, close_param: Span },
}
impl AddSubdiagnostic for AssocTyParenthesesSub {
impl AddToDiagnostic for AssocTyParenthesesSub {
fn add_to_diagnostic(self, diag: &mut Diagnostic) {
match self {
Self::Empty { parentheses_span } => diag.multipart_suggestion(

View File

@ -51,7 +51,7 @@ lint_non_existant_doc_keyword = found non-existing keyword `{$keyword}` used in
.help = only existing keywords are allowed in core/std
lint_diag_out_of_impl =
diagnostics should only be created in `IntoDiagnostic`/`AddSubdiagnostic` impls
diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls
lint_untranslatable_diag = diagnostics should be created using translatable messages

View File

@ -178,7 +178,7 @@ impl IntoDiagnosticArg for hir::ConstContext {
/// Trait implemented by error types. This should not be implemented manually. Instead, use
/// `#[derive(SessionSubdiagnostic)]` -- see [rustc_macros::SessionSubdiagnostic].
#[rustc_diagnostic_item = "AddSubdiagnostic"]
pub trait AddSubdiagnostic {
pub trait AddToDiagnostic {
/// Add a subdiagnostic to an existing diagnostic.
fn add_to_diagnostic(self, diag: &mut Diagnostic);
}
@ -893,7 +893,7 @@ impl Diagnostic {
/// Add a subdiagnostic from a type that implements `SessionSubdiagnostic` - see
/// [rustc_macros::SessionSubdiagnostic].
pub fn subdiagnostic(&mut self, subdiagnostic: impl AddSubdiagnostic) -> &mut Self {
pub fn subdiagnostic(&mut self, subdiagnostic: impl AddToDiagnostic) -> &mut Self {
subdiagnostic.add_to_diagnostic(self);
self
}

View File

@ -580,7 +580,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
forward!(pub fn subdiagnostic(
&mut self,
subdiagnostic: impl crate::AddSubdiagnostic
subdiagnostic: impl crate::AddToDiagnostic
) -> &mut Self);
}

View File

@ -371,7 +371,7 @@ impl fmt::Display for ExplicitBug {
impl error::Error for ExplicitBug {}
pub use diagnostic::{
AddSubdiagnostic, DecorateLint, Diagnostic, DiagnosticArg, DiagnosticArgFromDisplay,
AddToDiagnostic, DecorateLint, Diagnostic, DiagnosticArg, DiagnosticArgFromDisplay,
DiagnosticArgValue, DiagnosticId, DiagnosticStyledString, IntoDiagnosticArg, SubDiagnostic,
};
pub use diagnostic_builder::{DiagnosticBuilder, EmissionGuarantee, LintDiagnosticBuilder};

View File

@ -2,7 +2,7 @@ use crate::errors::RegionOriginNote;
use crate::infer::error_reporting::note_and_explain_region;
use crate::infer::{self, InferCtxt, SubregionOrigin};
use rustc_errors::{
fluent, struct_span_err, AddSubdiagnostic, Diagnostic, DiagnosticBuilder, ErrorGuaranteed,
fluent, struct_span_err, AddToDiagnostic, Diagnostic, DiagnosticBuilder, ErrorGuaranteed,
};
use rustc_middle::traits::ObligationCauseCode;
use rustc_middle::ty::error::TypeError;

View File

@ -1,4 +1,4 @@
use rustc_errors::{fluent, AddSubdiagnostic, IntoDiagnostic, ErrorGuaranteed, Handler};
use rustc_errors::{fluent, AddToDiagnostic, IntoDiagnostic, ErrorGuaranteed, Handler};
use rustc_macros::{DiagnosticHandler, SessionSubdiagnostic};
use rustc_session::lint::Level;
use rustc_span::{Span, Symbol};
@ -22,7 +22,7 @@ pub enum OverruledAttributeSub {
CommandLineSource,
}
impl AddSubdiagnostic for OverruledAttributeSub {
impl AddToDiagnostic for OverruledAttributeSub {
fn add_to_diagnostic(self, diag: &mut rustc_errors::Diagnostic) {
match self {
OverruledAttributeSub::DefaultSource { id } => {
@ -87,7 +87,7 @@ pub struct RequestedLevel {
pub lint_name: String,
}
impl AddSubdiagnostic for RequestedLevel {
impl AddToDiagnostic for RequestedLevel {
fn add_to_diagnostic(self, diag: &mut rustc_errors::Diagnostic) {
diag.note(fluent::lint::requested_level);
diag.set_arg(

View File

@ -372,7 +372,7 @@ declare_tool_lint! {
declare_tool_lint! {
pub rustc::DIAGNOSTIC_OUTSIDE_OF_IMPL,
Allow,
"prevent creation of diagnostics outside of `DiagnosticHandler`/`AddSubdiagnostic` impls",
"prevent creation of diagnostics outside of `DiagnosticHandler`/`AddToDiagnostic` impls",
report_in_external_macro: true
}

View File

@ -166,7 +166,7 @@ impl<'a> SessionSubdiagnosticDerive<'a> {
};
let ret = structure.gen_impl(quote! {
gen impl rustc_errors::AddSubdiagnostic for @Self {
gen impl rustc_errors::AddToDiagnostic for @Self {
fn add_to_diagnostic(self, #diag: &mut rustc_errors::Diagnostic) {
use rustc_errors::{Applicability, IntoDiagnosticArg};
#implementation

View File

@ -12,7 +12,7 @@ extern crate rustc_session;
extern crate rustc_span;
use rustc_errors::{
AddSubdiagnostic, IntoDiagnostic, Diagnostic, DiagnosticBuilder,
AddToDiagnostic, IntoDiagnostic, Diagnostic, DiagnosticBuilder,
ErrorGuaranteed, Handler, fluent
};
use rustc_macros::{DiagnosticHandler, SessionSubdiagnostic};
@ -49,18 +49,18 @@ impl<'a> IntoDiagnostic<'a, ErrorGuaranteed> for TranslatableInSessionDiagnostic
}
}
pub struct UntranslatableInAddSubdiagnostic;
pub struct UntranslatableInAddToDiagnostic;
impl AddSubdiagnostic for UntranslatableInAddSubdiagnostic {
impl AddToDiagnostic for UntranslatableInAddToDiagnostic {
fn add_to_diagnostic(self, diag: &mut Diagnostic) {
diag.note("untranslatable diagnostic");
//~^ ERROR diagnostics should be created using translatable messages
}
}
pub struct TranslatableInAddSubdiagnostic;
pub struct TranslatableInAddToDiagnostic;
impl AddSubdiagnostic for TranslatableInAddSubdiagnostic {
impl AddToDiagnostic for TranslatableInAddToDiagnostic {
fn add_to_diagnostic(self, diag: &mut Diagnostic) {
diag.note(fluent::typeck::note);
}
@ -68,10 +68,10 @@ impl AddSubdiagnostic for TranslatableInAddSubdiagnostic {
pub fn make_diagnostics<'a>(handler: &'a Handler) {
let _diag = handler.struct_err(fluent::parser::expect_path);
//~^ ERROR diagnostics should only be created in `IntoDiagnostic`/`AddSubdiagnostic` impls
//~^ ERROR diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls
let _diag = handler.struct_err("untranslatable diagnostic");
//~^ ERROR diagnostics should only be created in `IntoDiagnostic`/`AddSubdiagnostic` impls
//~^ ERROR diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls
//~^^ ERROR diagnostics should be created using translatable messages
}

View File

@ -16,7 +16,7 @@ error: diagnostics should be created using translatable messages
LL | diag.note("untranslatable diagnostic");
| ^^^^
error: diagnostics should only be created in `IntoDiagnostic`/`AddSubdiagnostic` impls
error: diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls
--> $DIR/diagnostics.rs:70:25
|
LL | let _diag = handler.struct_err(fluent::parser::expect_path);
@ -28,7 +28,7 @@ note: the lint level is defined here
LL | #![deny(rustc::diagnostic_outside_of_impl)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: diagnostics should only be created in `IntoDiagnostic`/`AddSubdiagnostic` impls
error: diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls
--> $DIR/diagnostics.rs:73:25
|
LL | let _diag = handler.struct_err("untranslatable diagnostic");