mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Add wrapper type for ExitCode for use in RanlibFailure
This commit is contained in:
parent
fb488ad366
commit
e906ea80fe
@ -183,7 +183,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'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