diff options
| author | Jake Goulding <jake.goulding@gmail.com> | 2025-03-21 10:09:17 -0400 |
|---|---|---|
| committer | Jake Goulding <jake.goulding@gmail.com> | 2025-04-16 21:38:59 -0400 |
| commit | 01178849174bdff3e3e951827d9ea4884c23b758 (patch) | |
| tree | 6d31d9058e1ef856ed57631bc0210f129190b547 /compiler/rustc_trait_selection/src/errors | |
| parent | 78f2104e334068d5a892a170d50193c0025c690e (diff) | |
| download | rust-01178849174bdff3e3e951827d9ea4884c23b758.tar.gz rust-01178849174bdff3e3e951827d9ea4884c23b758.zip | |
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`.
Diffstat (limited to 'compiler/rustc_trait_selection/src/errors')
| -rw-r--r-- | compiler/rustc_trait_selection/src/errors/note_and_explain.rs | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/compiler/rustc_trait_selection/src/errors/note_and_explain.rs b/compiler/rustc_trait_selection/src/errors/note_and_explain.rs index e4ab78b6247..84e7686fdd3 100644 --- a/compiler/rustc_trait_selection/src/errors/note_and_explain.rs +++ b/compiler/rustc_trait_selection/src/errors/note_and_explain.rs @@ -1,4 +1,4 @@ -use rustc_errors::{Diag, EmissionGuarantee, IntoDiagArg, SubdiagMessageOp, Subdiagnostic}; +use rustc_errors::{Diag, EmissionGuarantee, IntoDiagArg, Subdiagnostic}; use rustc_hir::def_id::LocalDefId; use rustc_middle::bug; use rustc_middle::ty::{self, TyCtxt}; @@ -162,17 +162,13 @@ impl RegionExplanation<'_> { } impl Subdiagnostic for RegionExplanation<'_> { - 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("pref_kind", self.prefix); diag.arg("suff_kind", self.suffix); diag.arg("desc_kind", self.desc.kind); diag.arg("desc_arg", self.desc.arg); - let msg = f(diag, fluent::trait_selection_region_explanation.into()); + let msg = diag.eagerly_translate(fluent::trait_selection_region_explanation); if let Some(span) = self.desc.span { diag.span_note(span, msg); } else { |
