Skip to content

Commit 9363f0f

Browse files
committed
Add RanlibFailure
1 parent 6580010 commit 9363f0f

File tree

6 files changed

+24
-1
lines changed

6 files changed

+24
-1
lines changed

compiler/rustc_codegen_gcc/src/archive.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
use std::fs::File;
22
use std::path::{Path, PathBuf};
33

4+
use crate::errors::RanlibFailure;
5+
46
use rustc_codegen_ssa::back::archive::{ArchiveBuilder, ArchiveBuilderBuilder};
57
use rustc_session::Session;
68

@@ -181,7 +183,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
181183
std::process::Command::new("ranlib").arg(output).status().expect("Couldn't run ranlib");
182184

183185
if !status.success() {
184-
self.config.sess.fatal(&format!("Ranlib exited with code {:?}", status.code()));
186+
self.config.sess.emit_fatal(RanlibFailure { exit_code: status.code() });
185187
}
186188

187189
any_members
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
use rustc_macros::SessionDiagnostic;
2+
3+
#[derive(SessionDiagnostic)]
4+
#[diag(codegen_gcc::ranlib_failure)]
5+
pub(crate) struct RanlibFailure {
6+
pub exit_code: Option<i32>
7+
}

compiler/rustc_codegen_gcc/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ extern crate rustc_codegen_ssa;
2525
extern crate rustc_data_structures;
2626
extern crate rustc_errors;
2727
extern crate rustc_hir;
28+
extern crate rustc_macros;
2829
extern crate rustc_metadata;
2930
extern crate rustc_middle;
3031
extern crate rustc_session;
@@ -50,6 +51,7 @@ mod context;
5051
mod coverageinfo;
5152
mod debuginfo;
5253
mod declare;
54+
mod errors;
5355
mod int;
5456
mod intrinsic;
5557
mod mono_item;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
codegen_gcc_ranlib_failure =
2+
Ranlib exited with code {$exit_code}

compiler/rustc_error_messages/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ fluent_messages! {
4141
borrowck => "../locales/en-US/borrowck.ftl",
4242
builtin_macros => "../locales/en-US/builtin_macros.ftl",
4343
const_eval => "../locales/en-US/const_eval.ftl",
44+
codegen_gcc => "../locales/en-US/codegen_gcc.ftl",
4445
driver => "../locales/en-US/driver.ftl",
4546
expand => "../locales/en-US/expand.ftl",
4647
session => "../locales/en-US/session.ftl",

compiler/rustc_errors/src/diagnostic.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,15 @@ impl IntoDiagnosticArg for char {
114114
}
115115
}
116116

117+
impl<T: IntoDiagnosticArg> IntoDiagnosticArg for Option<T> {
118+
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
119+
match self {
120+
Some(t) => t.into_diagnostic_arg(),
121+
None => DiagnosticArgValue::Str(Cow::Borrowed("None")),
122+
}
123+
}
124+
}
125+
117126
impl IntoDiagnosticArg for Symbol {
118127
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
119128
self.to_ident_string().into_diagnostic_arg()

0 commit comments

Comments
 (0)