mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 07:14:28 +00:00
Rollup merge of #106425 - ijackson:exit-status-default, r=dtolnay
Make ExitStatus implement Default And, necessarily, make it inhabited even on platforms without processes. I noticed while preparing https://github.com/rust-lang/rfcs/pull/3362 that there was no way for anyone to construct an `ExitStatus`. This would be insta-stable so needs an FCP.
This commit is contained in:
commit
b3550891e8
@ -1528,7 +1528,7 @@ impl From<fs::File> for Stdio {
|
||||
// vs `_exit`. Naming of Unix system calls is not standardised across Unices, so terminology is a
|
||||
// matter of convention and tradition. For clarity we usually speak of `exit`, even when we might
|
||||
// mean an underlying system call such as `_exit`.
|
||||
#[derive(PartialEq, Eq, Clone, Copy, Debug)]
|
||||
#[derive(PartialEq, Eq, Clone, Copy, Debug, Default)]
|
||||
#[stable(feature = "process", since = "1.0.0")]
|
||||
pub struct ExitStatus(imp::ExitStatus);
|
||||
|
||||
|
@ -235,7 +235,7 @@ impl Process {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Clone, Copy, Debug)]
|
||||
#[derive(PartialEq, Eq, Clone, Copy, Debug, Default)]
|
||||
pub struct ExitStatus(i64);
|
||||
|
||||
impl ExitStatus {
|
||||
|
@ -800,7 +800,7 @@ impl Process {
|
||||
//
|
||||
// This is not actually an "exit status" in Unix terminology. Rather, it is a "wait status".
|
||||
// See the discussion in comments and doc comments for `std::process::ExitStatus`.
|
||||
#[derive(PartialEq, Eq, Clone, Copy)]
|
||||
#[derive(PartialEq, Eq, Clone, Copy, Default)]
|
||||
pub struct ExitStatus(c_int);
|
||||
|
||||
impl fmt::Debug for ExitStatus {
|
||||
|
@ -55,7 +55,7 @@ impl Process {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Clone, Copy, Debug)]
|
||||
#[derive(PartialEq, Eq, Clone, Copy, Debug, Default)]
|
||||
pub struct ExitStatus(c_int);
|
||||
|
||||
impl ExitStatus {
|
||||
|
@ -179,7 +179,7 @@ impl Process {
|
||||
}
|
||||
|
||||
/// Unix exit statuses
|
||||
#[derive(PartialEq, Eq, Clone, Copy, Debug)]
|
||||
#[derive(PartialEq, Eq, Clone, Copy, Debug, Default)]
|
||||
pub struct ExitStatus(c_int);
|
||||
|
||||
impl ExitStatus {
|
||||
|
@ -99,58 +99,59 @@ impl fmt::Debug for Command {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ExitStatus(!);
|
||||
#[derive(PartialEq, Eq, Clone, Copy, Debug, Default)]
|
||||
#[non_exhaustive]
|
||||
pub struct ExitStatus();
|
||||
|
||||
impl ExitStatus {
|
||||
pub fn exit_ok(&self) -> Result<(), ExitStatusError> {
|
||||
self.0
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn code(&self) -> Option<i32> {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl Clone for ExitStatus {
|
||||
fn clone(&self) -> ExitStatus {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl Copy for ExitStatus {}
|
||||
|
||||
impl PartialEq for ExitStatus {
|
||||
fn eq(&self, _other: &ExitStatus) -> bool {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl Eq for ExitStatus {}
|
||||
|
||||
impl fmt::Debug for ExitStatus {
|
||||
fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
self.0
|
||||
Some(0)
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for ExitStatus {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "<dummy exit status>")
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ExitStatusError(!);
|
||||
|
||||
impl Clone for ExitStatusError {
|
||||
fn clone(&self) -> ExitStatusError {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl Copy for ExitStatusError {}
|
||||
|
||||
impl PartialEq for ExitStatusError {
|
||||
fn eq(&self, _other: &ExitStatusError) -> bool {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl Eq for ExitStatusError {}
|
||||
|
||||
impl fmt::Debug for ExitStatusError {
|
||||
fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Clone, Copy, Debug)]
|
||||
pub struct ExitStatusError(ExitStatus);
|
||||
|
||||
impl Into<ExitStatus> for ExitStatusError {
|
||||
fn into(self) -> ExitStatus {
|
||||
self.0.0
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl ExitStatusError {
|
||||
pub fn code(self) -> Option<NonZeroI32> {
|
||||
self.0.0
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -652,7 +652,7 @@ impl Process {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Clone, Copy, Debug)]
|
||||
#[derive(PartialEq, Eq, Clone, Copy, Debug, Default)]
|
||||
pub struct ExitStatus(c::DWORD);
|
||||
|
||||
impl ExitStatus {
|
||||
|
Loading…
Reference in New Issue
Block a user