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

@ -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");