diff --git a/compiler/rustc_driver/src/lib.rs b/compiler/rustc_driver/src/lib.rs index 33af7fd0e42..90e4d629b61 100644 --- a/compiler/rustc_driver/src/lib.rs +++ b/compiler/rustc_driver/src/lib.rs @@ -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); diff --git a/compiler/rustc_driver/src/session_diagnostics.rs b/compiler/rustc_driver/src/session_diagnostics.rs index ed10a66c823..a5dbef45475 100644 --- a/compiler/rustc_driver/src/session_diagnostics.rs +++ b/compiler/rustc_driver/src/session_diagnostics.rs @@ -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; diff --git a/compiler/rustc_error_messages/locales/en-US/driver.ftl b/compiler/rustc_error_messages/locales/en-US/driver.ftl index 57104612cc8..0a2f0e8f883 100644 --- a/compiler/rustc_error_messages/locales/en-US/driver.ftl +++ b/compiler/rustc_error_messages/locales/en-US/driver.ftl @@ -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}`