Fix up some ui-fulldeps tests.

This commit is contained in:
Nicholas Nethercote 2023-12-18 14:13:53 +11:00
parent f6aa418c9f
commit 1e831e38ce
2 changed files with 22 additions and 22 deletions

View file

@ -13,7 +13,7 @@ extern crate rustc_session;
extern crate rustc_span;
use rustc_errors::{
AddToDiagnostic, Diagnostic, DiagnosticBuilder, DiagnosticMessage, ErrorGuaranteed, Handler,
AddToDiagnostic, DiagCtxt, Diagnostic, DiagnosticBuilder, DiagnosticMessage, ErrorGuaranteed,
IntoDiagnostic, SubdiagnosticMessage,
};
use rustc_macros::{Diagnostic, Subdiagnostic};
@ -38,8 +38,8 @@ struct Note {
pub struct UntranslatableInIntoDiagnostic;
impl<'a> IntoDiagnostic<'a, ErrorGuaranteed> for UntranslatableInIntoDiagnostic {
fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
handler.struct_err("untranslatable diagnostic")
fn into_diagnostic(self, dcx: &'a DiagCtxt) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
dcx.struct_err("untranslatable diagnostic")
//~^ ERROR diagnostics should be created using translatable messages
}
}
@ -47,8 +47,8 @@ impl<'a> IntoDiagnostic<'a, ErrorGuaranteed> for UntranslatableInIntoDiagnostic
pub struct TranslatableInIntoDiagnostic;
impl<'a> IntoDiagnostic<'a, ErrorGuaranteed> for TranslatableInIntoDiagnostic {
fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
handler.struct_err(crate::fluent_generated::no_crate_example)
fn into_diagnostic(self, dcx: &'a DiagCtxt) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
dcx.struct_err(crate::fluent_generated::no_crate_example)
}
}
@ -75,11 +75,11 @@ impl AddToDiagnostic for TranslatableInAddToDiagnostic {
}
}
pub fn make_diagnostics<'a>(handler: &'a Handler) {
let _diag = handler.struct_err(crate::fluent_generated::no_crate_example);
pub fn make_diagnostics<'a>(dcx: &'a DiagCtxt) {
let _diag = dcx.struct_err(crate::fluent_generated::no_crate_example);
//~^ ERROR diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls
let _diag = handler.struct_err("untranslatable diagnostic");
let _diag = dcx.struct_err("untranslatable diagnostic");
//~^ ERROR diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls
//~^^ ERROR diagnostics should be created using translatable messages
}
@ -87,6 +87,6 @@ pub fn make_diagnostics<'a>(handler: &'a Handler) {
// Check that `rustc_lint_diagnostics`-annotated functions aren't themselves linted.
#[rustc_lint_diagnostics]
pub fn skipped_because_of_annotation<'a>(handler: &'a Handler) {
let _diag = handler.struct_err("untranslatable diagnostic"); // okay!
pub fn skipped_because_of_annotation<'a>(dcx: &'a DiagCtxt) {
let _diag = dcx.struct_err("untranslatable diagnostic"); // okay!
}

View file

@ -1,8 +1,8 @@
error: diagnostics should be created using translatable messages
--> $DIR/diagnostics.rs:42:17
--> $DIR/diagnostics.rs:42:13
|
LL | handler.struct_err("untranslatable diagnostic")
| ^^^^^^^^^^
LL | dcx.struct_err("untranslatable diagnostic")
| ^^^^^^^^^^
|
note: the lint level is defined here
--> $DIR/diagnostics.rs:6:9
@ -17,10 +17,10 @@ LL | diag.note("untranslatable diagnostic");
| ^^^^
error: diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls
--> $DIR/diagnostics.rs:79:25
--> $DIR/diagnostics.rs:79:21
|
LL | let _diag = handler.struct_err(crate::fluent_generated::no_crate_example);
| ^^^^^^^^^^
LL | let _diag = dcx.struct_err(crate::fluent_generated::no_crate_example);
| ^^^^^^^^^^
|
note: the lint level is defined here
--> $DIR/diagnostics.rs:7:9
@ -29,16 +29,16 @@ LL | #![deny(rustc::diagnostic_outside_of_impl)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls
--> $DIR/diagnostics.rs:82:25
--> $DIR/diagnostics.rs:82:21
|
LL | let _diag = handler.struct_err("untranslatable diagnostic");
| ^^^^^^^^^^
LL | let _diag = dcx.struct_err("untranslatable diagnostic");
| ^^^^^^^^^^
error: diagnostics should be created using translatable messages
--> $DIR/diagnostics.rs:82:25
--> $DIR/diagnostics.rs:82:21
|
LL | let _diag = handler.struct_err("untranslatable diagnostic");
| ^^^^^^^^^^
LL | let _diag = dcx.struct_err("untranslatable diagnostic");
| ^^^^^^^^^^
error: aborting due to 5 previous errors