UPDATE - LibDefWriteFailure to accept type instead of formatted string

This follows team’s suggestions in this thread https://rust-lang.zulipchat.com/#narrow/stream/336883-i18n/topic/.23100717.20diag.20translation/near/295305249
This commit is contained in:
Jhonny Bill Mena 2022-08-26 20:21:55 -04:00
parent 4e0de5319c
commit 0a2d7f83cb
3 changed files with 9 additions and 8 deletions

View File

@ -666,8 +666,8 @@ impl<'a> Linker for GccLinker<'a> {
writeln!(f, "_{}", sym)?; writeln!(f, "_{}", sym)?;
} }
}; };
if let Err(e) = res { if let Err(error) = res {
self.sess.emit_fatal(LibDefWriteFailure { error_description: format!("{e}") }); self.sess.emit_fatal(LibDefWriteFailure { error });
} }
} else if is_windows { } else if is_windows {
let res: io::Result<()> = try { let res: io::Result<()> = try {
@ -681,8 +681,8 @@ impl<'a> Linker for GccLinker<'a> {
writeln!(f, " {}", symbol)?; writeln!(f, " {}", symbol)?;
} }
}; };
if let Err(e) = res { if let Err(error) = res {
self.sess.emit_fatal(LibDefWriteFailure { error_description: format!("{e}") }); self.sess.emit_fatal(LibDefWriteFailure { error });
} }
} else { } else {
// Write an LD version script // Write an LD version script
@ -972,8 +972,8 @@ impl<'a> Linker for MsvcLinker<'a> {
writeln!(f, " {}", symbol)?; writeln!(f, " {}", symbol)?;
} }
}; };
if let Err(e) = res { if let Err(error) = res {
self.sess.emit_fatal(LibDefWriteFailure { error_description: format!("{e}") }); self.sess.emit_fatal(LibDefWriteFailure { error });
} }
let mut arg = OsString::from("/DEF:"); let mut arg = OsString::from("/DEF:");
arg.push(path); arg.push(path);

View File

@ -1,6 +1,7 @@
//! Errors emitted by codegen_ssa //! Errors emitted by codegen_ssa
use rustc_macros::SessionDiagnostic; use rustc_macros::SessionDiagnostic;
use std::io::Error;
#[derive(SessionDiagnostic)] #[derive(SessionDiagnostic)]
#[diag(codegen_ssa::missing_native_static_library)] #[diag(codegen_ssa::missing_native_static_library)]
@ -11,5 +12,5 @@ pub struct MissingNativeStaticLibrary<'a> {
#[derive(SessionDiagnostic)] #[derive(SessionDiagnostic)]
#[diag(codegen_ssa::lib_def_write_failure)] #[diag(codegen_ssa::lib_def_write_failure)]
pub struct LibDefWriteFailure { pub struct LibDefWriteFailure {
pub error_description: String, pub error: Error,
} }

View File

@ -1,3 +1,3 @@
codegen_ssa_missing_native_static_library = could not find native static library `{$library_name}`, perhaps an -L flag is missing? codegen_ssa_missing_native_static_library = could not find native static library `{$library_name}`, perhaps an -L flag is missing?
codegen_ssa_lib_def_write_failure = failed to write lib.def file: {$error_description} codegen_ssa_lib_def_write_failure = failed to write lib.def file: {$error}