diff options
Diffstat (limited to 'src/test/ui-fulldeps/internal-lints/diagnostics.rs')
-rw-r--r-- | src/test/ui-fulldeps/internal-lints/diagnostics.rs | 52 |
1 files changed, 29 insertions, 23 deletions
diff --git a/src/test/ui-fulldeps/internal-lints/diagnostics.rs b/src/test/ui-fulldeps/internal-lints/diagnostics.rs index e9e809fa4..643e81d99 100644 --- a/src/test/ui-fulldeps/internal-lints/diagnostics.rs +++ b/src/test/ui-fulldeps/internal-lints/diagnostics.rs @@ -12,66 +12,72 @@ extern crate rustc_session; extern crate rustc_span; use rustc_errors::{ - AddSubdiagnostic, Diagnostic, DiagnosticBuilder, ErrorGuaranteed, Handler, fluent + AddToDiagnostic, IntoDiagnostic, Diagnostic, DiagnosticBuilder, + ErrorGuaranteed, Handler, fluent, SubdiagnosticMessage, }; -use rustc_macros::{SessionDiagnostic, SessionSubdiagnostic}; -use rustc_session::SessionDiagnostic; +use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_span::Span; -#[derive(SessionDiagnostic)] -#[diag(parser::expect_path)] -struct DeriveSessionDiagnostic { +#[derive(Diagnostic)] +#[diag(compiletest_example)] +struct DeriveDiagnostic { #[primary_span] span: Span, } -#[derive(SessionSubdiagnostic)] -#[note(parser::add_paren)] +#[derive(Subdiagnostic)] +#[note(compiletest_example)] struct Note { #[primary_span] span: Span, } -pub struct UntranslatableInSessionDiagnostic; +pub struct UntranslatableInIntoDiagnostic; -impl<'a> SessionDiagnostic<'a, ErrorGuaranteed> for UntranslatableInSessionDiagnostic { +impl<'a> IntoDiagnostic<'a, ErrorGuaranteed> for UntranslatableInIntoDiagnostic { fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, ErrorGuaranteed> { handler.struct_err("untranslatable diagnostic") //~^ ERROR diagnostics should be created using translatable messages } } -pub struct TranslatableInSessionDiagnostic; +pub struct TranslatableInIntoDiagnostic; -impl<'a> SessionDiagnostic<'a, ErrorGuaranteed> for TranslatableInSessionDiagnostic { +impl<'a> IntoDiagnostic<'a, ErrorGuaranteed> for TranslatableInIntoDiagnostic { fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, ErrorGuaranteed> { - handler.struct_err(fluent::parser::expect_path) + handler.struct_err(fluent::compiletest_example) } } -pub struct UntranslatableInAddSubdiagnostic; +pub struct UntranslatableInAddToDiagnostic; -impl AddSubdiagnostic for UntranslatableInAddSubdiagnostic { - fn add_to_diagnostic(self, diag: &mut Diagnostic) { +impl AddToDiagnostic for UntranslatableInAddToDiagnostic { + fn add_to_diagnostic_with<F>(self, diag: &mut Diagnostic, _: F) + where + F: Fn(&mut Diagnostic, SubdiagnosticMessage) -> SubdiagnosticMessage, + { diag.note("untranslatable diagnostic"); //~^ ERROR diagnostics should be created using translatable messages } } -pub struct TranslatableInAddSubdiagnostic; +pub struct TranslatableInAddToDiagnostic; -impl AddSubdiagnostic for TranslatableInAddSubdiagnostic { - fn add_to_diagnostic(self, diag: &mut Diagnostic) { - diag.note(fluent::typeck::note); +impl AddToDiagnostic for TranslatableInAddToDiagnostic { + fn add_to_diagnostic_with<F>(self, diag: &mut Diagnostic, _: F) + where + F: Fn(&mut Diagnostic, SubdiagnosticMessage) -> SubdiagnosticMessage, + { + diag.note(fluent::note); } } pub fn make_diagnostics<'a>(handler: &'a Handler) { - let _diag = handler.struct_err(fluent::parser::expect_path); - //~^ ERROR diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls + let _diag = handler.struct_err(fluent::compiletest_example); + //~^ ERROR diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls let _diag = handler.struct_err("untranslatable diagnostic"); - //~^ ERROR diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls + //~^ ERROR diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls //~^^ ERROR diagnostics should be created using translatable messages } |