diff options
| author | Matthias Krüger <476013+matthiaskrgr@users.noreply.github.com> | 2025-04-17 06:25:18 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-17 06:25:18 +0200 |
| commit | 059b7d07efcd658d4398969afadf0b1fd613f866 (patch) | |
| tree | 02f4124bd7fcc79f9e77f2017a5e1469c088000b /compiler/rustc_builtin_macros/src/errors.rs | |
| parent | a7af610058329592b987c3e17ed3b1ac03e19ccd (diff) | |
| parent | 01178849174bdff3e3e951827d9ea4884c23b758 (diff) | |
| download | rust-059b7d07efcd658d4398969afadf0b1fd613f866.tar.gz rust-059b7d07efcd658d4398969afadf0b1fd613f866.zip | |
Rollup merge of #139944 - shepmaster:eager-diagnostics, r=nnethercote
Move eager translation to a method on Diag This will allow us to eagerly translate messages on a top-level diagnostic, such as a `LintDiagnostic`. As a bonus, we can remove the awkward closure passed into Subdiagnostic and make better use of `Into`. r? `@nnethercote`
Diffstat (limited to 'compiler/rustc_builtin_macros/src/errors.rs')
| -rw-r--r-- | compiler/rustc_builtin_macros/src/errors.rs | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/compiler/rustc_builtin_macros/src/errors.rs b/compiler/rustc_builtin_macros/src/errors.rs index c2b1dff4cf1..d14ad8f4014 100644 --- a/compiler/rustc_builtin_macros/src/errors.rs +++ b/compiler/rustc_builtin_macros/src/errors.rs @@ -1,7 +1,7 @@ use rustc_errors::codes::*; use rustc_errors::{ Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level, MultiSpan, SingleLabelManySpans, - SubdiagMessageOp, Subdiagnostic, + Subdiagnostic, }; use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_span::{Ident, Span, Symbol}; @@ -684,13 +684,9 @@ pub(crate) struct FormatUnusedArg { // Allow the singular form to be a subdiagnostic of the multiple-unused // form of diagnostic. impl Subdiagnostic for FormatUnusedArg { - fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>( - self, - diag: &mut Diag<'_, G>, - f: &F, - ) { + fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) { diag.arg("named", self.named); - let msg = f(diag, crate::fluent_generated::builtin_macros_format_unused_arg.into()); + let msg = diag.eagerly_translate(crate::fluent_generated::builtin_macros_format_unused_arg); diag.span_label(self.span, msg); } } |
