Use std::io::Error and remove useless to_string

This commit is contained in:
Adrian Tombu 2022-08-24 14:12:39 +02:00
parent e7ded9246c
commit 1c575c5fe0
No known key found for this signature in database
GPG Key ID: 9CD8E979D3A943FE
3 changed files with 6 additions and 6 deletions

View File

@ -586,12 +586,12 @@ pub fn try_process_rlink(sess: &Session, compiler: &interface::Compiler) -> Comp
sess.init_crate_types(collect_crate_types(sess, &[]));
let outputs = compiler.build_output_filenames(sess, &[]);
let rlink_data = fs::read(file).unwrap_or_else(|err| {
sess.emit_fatal(RlinkUnableToRead { error_message: err.to_string() });
sess.emit_fatal(RlinkUnableToRead { err });
});
let codegen_results = match CodegenResults::deserialize_rlink(rlink_data) {
Ok(codegen) => codegen,
Err(error) => {
sess.emit_fatal(RlinkUnableToDeserialize { error_message: error.to_string() });
Err(error_message) => {
sess.emit_fatal(RlinkUnableToDeserialize { error_message });
}
};
let result = compiler.codegen_backend().link(sess, codegen_results, &outputs);

View File

@ -3,7 +3,7 @@ use rustc_macros::SessionDiagnostic;
#[derive(SessionDiagnostic)]
#[diag(driver::rlink_unable_to_read)]
pub(crate) struct RlinkUnableToRead {
pub error_message: String,
pub err: std::io::Error,
}
#[derive(SessionDiagnostic)]
@ -14,4 +14,4 @@ pub(crate) struct RlinkUnableToDeserialize {
#[derive(SessionDiagnostic)]
#[diag(driver::rlink_no_a_file)]
pub(crate) struct RlinkNotAFile {}
pub(crate) struct RlinkNotAFile;

View File

@ -1,4 +1,4 @@
driver_rlink_unable_to_read = failed to read rlink file: `{$error_message}`
driver_rlink_unable_to_read = failed to read rlink file: `{$err}`
driver_rlink_unable_to_deserialize = could not deserialize .rlink file: `{$error_message}`