From 06aa381adbd5bac561c57dc6fc0390da8ec45b69 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Tue, 30 Jan 2024 15:52:20 +1100 Subject: [PATCH] Remove `DiagnosticArgName` from `rustc_codegen_ssa`. It's identical to the one in `rustc_errors`; use that instead. Also remove some `rustc_errors::` qualifiers. --- compiler/rustc_codegen_ssa/src/back/write.rs | 17 +++++++++-------- compiler/rustc_errors/src/lib.rs | 4 ++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/back/write.rs b/compiler/rustc_codegen_ssa/src/back/write.rs index affd386361c..562359a6b39 100644 --- a/compiler/rustc_codegen_ssa/src/back/write.rs +++ b/compiler/rustc_codegen_ssa/src/back/write.rs @@ -14,8 +14,11 @@ use rustc_data_structures::memmap::Mmap; use rustc_data_structures::profiling::{SelfProfilerRef, VerboseTimingGuard}; use rustc_data_structures::sync::Lrc; use rustc_errors::emitter::Emitter; -use rustc_errors::{translation::Translate, DiagCtxt, FatalError, Level}; -use rustc_errors::{DiagnosticBuilder, DiagnosticMessage, ErrCode, Style}; +use rustc_errors::translation::Translate; +use rustc_errors::{ + DiagCtxt, DiagnosticArgName, DiagnosticArgValue, DiagnosticBuilder, DiagnosticMessage, ErrCode, + FatalError, FluentBundle, Level, Style, +}; use rustc_fs_util::link_or_copy; use rustc_hir::def_id::{CrateNum, LOCAL_CRATE}; use rustc_incremental::{ @@ -995,11 +998,9 @@ pub(crate) enum Message { /// process another codegen unit. pub struct CguMessage; -type DiagnosticArgName<'source> = Cow<'source, str>; - struct Diagnostic { msgs: Vec<(DiagnosticMessage, Style)>, - args: FxHashMap, rustc_errors::DiagnosticArgValue>, + args: FxHashMap, DiagnosticArgValue>, code: Option, lvl: Level, } @@ -1800,18 +1801,18 @@ impl SharedEmitter { } impl Translate for SharedEmitter { - fn fluent_bundle(&self) -> Option<&Lrc> { + fn fluent_bundle(&self) -> Option<&Lrc> { None } - fn fallback_fluent_bundle(&self) -> &rustc_errors::FluentBundle { + fn fallback_fluent_bundle(&self) -> &FluentBundle { panic!("shared emitter attempted to translate a diagnostic"); } } impl Emitter for SharedEmitter { fn emit_diagnostic(&mut self, diag: &rustc_errors::Diagnostic) { - let args: FxHashMap, rustc_errors::DiagnosticArgValue> = + let args: FxHashMap, DiagnosticArgValue> = diag.args().map(|(name, arg)| (name.clone(), arg.clone())).collect(); drop(self.sender.send(SharedEmitterMessage::Diagnostic(Diagnostic { msgs: diag.messages.clone(), diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 6d9208341a5..295112c7c3c 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -33,8 +33,8 @@ extern crate self as rustc_errors; pub use codes::*; pub use diagnostic::{ - AddToDiagnostic, DecorateLint, Diagnostic, DiagnosticArg, DiagnosticArgValue, - DiagnosticStyledString, IntoDiagnosticArg, SubDiagnostic, + AddToDiagnostic, DecorateLint, Diagnostic, DiagnosticArg, DiagnosticArgName, + DiagnosticArgValue, DiagnosticStyledString, IntoDiagnosticArg, SubDiagnostic, }; pub use diagnostic_builder::{ BugAbort, DiagnosticBuilder, EmissionGuarantee, FatalAbort, IntoDiagnostic,