From 9449218d942752aa86d11bb4c888abc1a0db73d2 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Mon, 18 Dec 2023 14:13:53 +1100 Subject: [PATCH] Fix up some `ui-fulldeps` tests. --- .../ui-fulldeps/internal-lints/diagnostics.rs | 20 ++++++++-------- .../internal-lints/diagnostics.stderr | 24 +++++++++---------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/tests/ui-fulldeps/internal-lints/diagnostics.rs b/tests/ui-fulldeps/internal-lints/diagnostics.rs index 7f545ead152ca..4b006151c64c6 100644 --- a/tests/ui-fulldeps/internal-lints/diagnostics.rs +++ b/tests/ui-fulldeps/internal-lints/diagnostics.rs @@ -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! } diff --git a/tests/ui-fulldeps/internal-lints/diagnostics.stderr b/tests/ui-fulldeps/internal-lints/diagnostics.stderr index 8e0535e021beb..d18db3cbbd37a 100644 --- a/tests/ui-fulldeps/internal-lints/diagnostics.stderr +++ b/tests/ui-fulldeps/internal-lints/diagnostics.stderr @@ -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