From 3b949eb7c1eff22e89c4889e191d916ad028ff28 Mon Sep 17 00:00:00 2001 From: SLASHLogin Date: Thu, 3 Nov 2022 13:09:25 +0100 Subject: [PATCH] Add `replace_args` method for `rustc_errors::diagnostic::Diagnostic` --- compiler/rustc_codegen_ssa/src/back/write.rs | 4 +--- compiler/rustc_errors/src/diagnostic.rs | 4 ++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/back/write.rs b/compiler/rustc_codegen_ssa/src/back/write.rs index 6e1a87ae9eb..f0e2e43509f 100644 --- a/compiler/rustc_codegen_ssa/src/back/write.rs +++ b/compiler/rustc_codegen_ssa/src/back/write.rs @@ -1792,9 +1792,7 @@ pub fn check(&self, sess: &Session, blocking: bool) { if let Some(code) = diag.code { d.code(code); } - for (name, arg) in diag.args { - d.set_arg(name, arg); - } + d.replace_args(diag.args); handler.emit_diagnostic(&mut d); } Ok(SharedEmitterMessage::InlineAsmError(cookie, msg, level, source)) => { diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs index b6370354b24..8c76db84392 100644 --- a/compiler/rustc_errors/src/diagnostic.rs +++ b/compiler/rustc_errors/src/diagnostic.rs @@ -940,6 +940,10 @@ pub fn set_arg( self } + pub fn replace_args(&mut self, args: FxHashMap, DiagnosticArgValue<'static>>) { + self.args = args; + } + pub fn styled_message(&self) -> &[(DiagnosticMessage, Style)] { &self.message }