Add wrapper type for ExitCode for use in RanlibFailure
This commit is contained in:
parent
ff9bf7b6b3
commit
d3bb849fe9
@ -183,7 +183,7 @@ enum BuilderKind<'a> {
|
||||
std::process::Command::new("ranlib").arg(output).status().expect("Couldn't run ranlib");
|
||||
|
||||
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
|
||||
|
@ -1,10 +1,32 @@
|
||||
use rustc_errors::{DiagnosticArgValue, IntoDiagnosticArg};
|
||||
use rustc_macros::SessionDiagnostic;
|
||||
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)]
|
||||
#[diag(codegen_gcc::ranlib_failure)]
|
||||
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)]
|
||||
|
Loading…
Reference in New Issue
Block a user