Skip to content

Commit 05ae7ec

Browse files
committed
Import error creating import library
1 parent 69d412a commit 05ae7ec

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

compiler/rustc_codegen_llvm/src/back/archive.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use std::str;
1212
use object::read::macho::FatArch;
1313

1414
use crate::common;
15+
use crate::errors::ErrorCreatingImportLibrary;
1516
use crate::llvm::archive_ro::{ArchiveRO, Child};
1617
use crate::llvm::{self, ArchiveKind, LLVMMachineType, LLVMRustCOFFShortExport};
1718
use rustc_codegen_ssa::back::archive::{ArchiveBuilder, ArchiveBuilderBuilder};
@@ -293,11 +294,10 @@ impl ArchiveBuilderBuilder for LlvmArchiveBuilderBuilder {
293294
};
294295

295296
if result == crate::llvm::LLVMRustResult::Failure {
296-
sess.fatal(&format!(
297-
"Error creating import library for {}: {}",
297+
sess.emit_fatal(ErrorCreatingImportLibrary {
298298
lib_name,
299-
llvm::last_error().unwrap_or("unknown LLVM error".to_string())
300-
));
299+
error: llvm::last_error().unwrap_or("unknown LLVM error".to_string()),
300+
});
301301
}
302302
};
303303

compiler/rustc_codegen_llvm/src/errors.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use rustc_errors::fluent;
22
use rustc_errors::DiagnosticBuilder;
3+
use rustc_macros::SessionDiagnostic;
34
use rustc_session::SessionDiagnostic;
45

56
pub(crate) enum UnknownCTargetFeature<'a> {
@@ -34,3 +35,10 @@ impl SessionDiagnostic<'_, ()> for UnknownCTargetFeature<'_> {
3435
}
3536
}
3637
}
38+
39+
#[derive(SessionDiagnostic)]
40+
#[diag(codegen_llvm::error_creating_import_library)]
41+
pub(crate) struct ErrorCreatingImportLibrary<'a> {
42+
pub lib_name: &'a str,
43+
pub error: String,
44+
}

compiler/rustc_error_messages/locales/en-US/codegen_llvm.ftl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ codegen_llvm_rust_feature =
1212
1313
codegen_llvm_unknown_feature_fill_request =
1414
consider filing a feature request
15+
16+
codegen_llvm_error_creating_import_library =
17+
Error creating import library for {$lib_name}: {$error}

0 commit comments

Comments
 (0)