about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
diff options
context:
space:
mode:
authorSLASHLogin <loginmlgxd@gmail.com>2022-08-26 19:01:22 +0200
committerSLASHLogin <loginmlgxd@gmail.com>2022-11-09 14:56:21 +0100
commitc01546fcd64f703cd6a406752621d0e18ccb6a5a (patch)
treeede6949b10341937cbe59804eb76ae651e208118 /compiler/rustc_codegen_llvm/src
parent81f7a8d7f1ddcbe9ed49757a925366d0041eda31 (diff)
downloadrust-c01546fcd64f703cd6a406752621d0e18ccb6a5a.tar.gz
rust-c01546fcd64f703cd6a406752621d0e18ccb6a5a.zip
Port `DlltoolFailImportLibrary` and implement `IntoDiagnosticArg` for `Cow<'a, str>`
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
-rw-r--r--compiler/rustc_codegen_llvm/src/back/archive.rs14
-rw-r--r--compiler/rustc_codegen_llvm/src/errors.rs9
2 files changed, 17 insertions, 6 deletions
diff --git a/compiler/rustc_codegen_llvm/src/back/archive.rs b/compiler/rustc_codegen_llvm/src/back/archive.rs
index e73e122ee68..9be104fde6c 100644
--- a/compiler/rustc_codegen_llvm/src/back/archive.rs
+++ b/compiler/rustc_codegen_llvm/src/back/archive.rs
@@ -13,7 +13,8 @@ use object::read::macho::FatArch;
 
 use crate::common;
 use crate::errors::{
-    ArchiveBuildFailure, ErrorCallingDllTool, ErrorCreatingImportLibrary, ErrorWritingDEFFile,
+    ArchiveBuildFailure, DlltoolFailImportLibrary, ErrorCallingDllTool, ErrorCreatingImportLibrary,
+    ErrorWritingDEFFile,
 };
 use crate::llvm::archive_ro::{ArchiveRO, Child};
 use crate::llvm::{self, ArchiveKind, LLVMMachineType, LLVMRustCOFFShortExport};
@@ -244,11 +245,12 @@ impl ArchiveBuilderBuilder for LlvmArchiveBuilderBuilder {
                 Err(e) => {
                     sess.emit_fatal(ErrorCallingDllTool { error: e });
                 }
-                Ok(output) if !output.status.success() => sess.fatal(&format!(
-                    "Dlltool could not create import library: {}\n{}",
-                    String::from_utf8_lossy(&output.stdout),
-                    String::from_utf8_lossy(&output.stderr)
-                )),
+                Ok(output) if !output.status.success() => {
+                    sess.emit_fatal(DlltoolFailImportLibrary {
+                        stdout: String::from_utf8_lossy(&output.stdout),
+                        stderr: String::from_utf8_lossy(&output.stderr),
+                    })
+                }
                 _ => {}
             }
         } else {
diff --git a/compiler/rustc_codegen_llvm/src/errors.rs b/compiler/rustc_codegen_llvm/src/errors.rs
index 4856cead152..68c2e692830 100644
--- a/compiler/rustc_codegen_llvm/src/errors.rs
+++ b/compiler/rustc_codegen_llvm/src/errors.rs
@@ -1,3 +1,5 @@
+use std::borrow::Cow;
+
 use rustc_errors::fluent;
 use rustc_errors::DiagnosticBuilder;
 use rustc_macros::SessionDiagnostic;
@@ -102,3 +104,10 @@ pub(crate) struct ErrorWritingDEFFile {
 pub(crate) struct ErrorCallingDllTool {
     pub error: std::io::Error,
 }
+
+#[derive(SessionDiagnostic)]
+#[diag(codegen_llvm::dlltool_fail_import_library)]
+pub(crate) struct DlltoolFailImportLibrary<'a> {
+    pub stdout: Cow<'a, str>,
+    pub stderr: Cow<'a, str>,
+}