Add wrapper type for ExitCode for use in RanlibFailure
This commit is contained in:
parent
c4149da9fd
commit
4718beead6
@ -183,7 +183,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
|
|||||||
std::process::Command::new("ranlib").arg(output).status().expect("Couldn't run ranlib");
|
std::process::Command::new("ranlib").arg(output).status().expect("Couldn't run ranlib");
|
||||||
|
|
||||||
if !status.success() {
|
if !status.success() {
|
||||||
self.config.sess.emit_fatal(RanlibFailure { exit_code: format!("{:?}", status.code()) });
|
self.config.sess.emit_fatal(RanlibFailure::new(status.code()));
|
||||||
}
|
}
|
||||||
|
|
||||||
any_members
|
any_members
|
||||||
|
@ -1,10 +1,32 @@
|
|||||||
|
use rustc_errors::{DiagnosticArgValue, IntoDiagnosticArg};
|
||||||
use rustc_macros::SessionDiagnostic;
|
use rustc_macros::SessionDiagnostic;
|
||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
|
use std::borrow::Cow;
|
||||||
|
|
||||||
|
struct ExitCode {
|
||||||
|
pub exit_code: Option<i32>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl IntoDiagnosticArg for ExitCode {
|
||||||
|
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||||
|
match self.exit_code {
|
||||||
|
Some(t) => t.into_diagnostic_arg(),
|
||||||
|
None => DiagnosticArgValue::Str(Cow::Borrowed("None")),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(SessionDiagnostic)]
|
||||||
#[diag(codegen_gcc::ranlib_failure)]
|
#[diag(codegen_gcc::ranlib_failure)]
|
||||||
pub(crate) struct RanlibFailure {
|
pub(crate) struct RanlibFailure {
|
||||||
pub exit_code: String,
|
exit_code: ExitCode,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RanlibFailure {
|
||||||
|
pub fn new(exit_code: Option<i32>) -> Self {
|
||||||
|
let exit_code = ExitCode{ exit_code };
|
||||||
|
RanlibFailure { exit_code }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(SessionDiagnostic)]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user