Skip to content

Commit 4e0de53

Browse files
committed
ADD - migrate lib.def write fatal error
This diagnostic has no UI test 🤔 Should we add some? If so, how?
1 parent b0b072d commit 4e0de53

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

compiler/rustc_codegen_ssa/src/back/linker.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use super::command::Command;
22
use super::symbol_export;
3+
use crate::errors::LibDefWriteFailure;
34
use rustc_span::symbol::sym;
45

56
use std::ffi::{OsStr, OsString};
@@ -666,7 +667,7 @@ impl<'a> Linker for GccLinker<'a> {
666667
}
667668
};
668669
if let Err(e) = res {
669-
self.sess.fatal(&format!("failed to write lib.def file: {}", e));
670+
self.sess.emit_fatal(LibDefWriteFailure { error_description: format!("{e}") });
670671
}
671672
} else if is_windows {
672673
let res: io::Result<()> = try {
@@ -681,7 +682,7 @@ impl<'a> Linker for GccLinker<'a> {
681682
}
682683
};
683684
if let Err(e) = res {
684-
self.sess.fatal(&format!("failed to write list.def file: {}", e));
685+
self.sess.emit_fatal(LibDefWriteFailure { error_description: format!("{e}") });
685686
}
686687
} else {
687688
// Write an LD version script
@@ -972,7 +973,7 @@ impl<'a> Linker for MsvcLinker<'a> {
972973
}
973974
};
974975
if let Err(e) = res {
975-
self.sess.fatal(&format!("failed to write lib.def file: {}", e));
976+
self.sess.emit_fatal(LibDefWriteFailure { error_description: format!("{e}") });
976977
}
977978
let mut arg = OsString::from("/DEF:");
978979
arg.push(path);

compiler/rustc_codegen_ssa/src/errors.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,9 @@ use rustc_macros::SessionDiagnostic;
77
pub struct MissingNativeStaticLibrary<'a> {
88
pub library_name: &'a str,
99
}
10+
11+
#[derive(SessionDiagnostic)]
12+
#[diag(codegen_ssa::lib_def_write_failure)]
13+
pub struct LibDefWriteFailure {
14+
pub error_description: String,
15+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
codegen_ssa_missing_native_static_library = could not find native static library `{$library_name}`, perhaps an -L flag is missing?
2+
3+
codegen_ssa_lib_def_write_failure = failed to write lib.def file: {$error_description}

0 commit comments

Comments
 (0)