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`.
This commit is contained in:
parent
78f2104e33
commit
0117884917
20 changed files with 98 additions and 271 deletions
|
@ -6,7 +6,7 @@ use rustc_abi::WrappingRange;
|
|||
use rustc_errors::codes::*;
|
||||
use rustc_errors::{
|
||||
Diag, DiagArgValue, DiagCtxtHandle, DiagMessage, Diagnostic, EmissionGuarantee, Level,
|
||||
MultiSpan, SubdiagMessageOp, Subdiagnostic,
|
||||
MultiSpan, Subdiagnostic,
|
||||
};
|
||||
use rustc_hir::ConstContext;
|
||||
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
|
||||
|
@ -290,11 +290,7 @@ pub struct FrameNote {
|
|||
}
|
||||
|
||||
impl Subdiagnostic for FrameNote {
|
||||
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("times", self.times);
|
||||
diag.arg("where_", self.where_);
|
||||
diag.arg("instance", self.instance);
|
||||
|
@ -302,7 +298,7 @@ impl Subdiagnostic for FrameNote {
|
|||
if self.has_label && !self.span.is_dummy() {
|
||||
span.push_span_label(self.span, fluent::const_eval_frame_note_last);
|
||||
}
|
||||
let msg = f(diag, fluent::const_eval_frame_note.into());
|
||||
let msg = diag.eagerly_translate(fluent::const_eval_frame_note);
|
||||
diag.span_note(span, msg);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue