From c9b0635679fc5bb4fd157e1eaad8e7f21705d68a Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Tue, 11 Apr 2023 17:29:51 +1000 Subject: [PATCH] Inline and remove `DescriptionCtx::add_to`. It has a single callsite. --- compiler/rustc_infer/src/errors/note_and_explain.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_infer/src/errors/note_and_explain.rs b/compiler/rustc_infer/src/errors/note_and_explain.rs index 744fb27635a..c4f2cf62ddd 100644 --- a/compiler/rustc_infer/src/errors/note_and_explain.rs +++ b/compiler/rustc_infer/src/errors/note_and_explain.rs @@ -108,11 +108,6 @@ impl<'a> DescriptionCtx<'a> { } Some(me) } - - fn add_to(self, diag: &mut rustc_errors::Diagnostic) { - diag.set_arg("desc_kind", self.kind); - diag.set_arg("desc_arg", self.arg); - } } pub enum PrefixKind { @@ -196,10 +191,11 @@ impl AddToDiagnostic for RegionExplanation<'_> { { diag.set_arg("pref_kind", self.prefix); diag.set_arg("suff_kind", self.suffix); - let desc_span = self.desc.span; - self.desc.add_to(diag); + diag.set_arg("desc_kind", self.desc.kind); + diag.set_arg("desc_arg", self.desc.arg); + let msg = f(diag, fluent::infer_region_explanation.into()); - if let Some(span) = desc_span { + if let Some(span) = self.desc.span { diag.span_note(span, msg); } else { diag.note(msg);