mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 01:04:03 +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
|
// 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
|
// matter of convention and tradition. For clarity we usually speak of `exit`, even when we might
|
||||||
// mean an underlying system call such as `_exit`.
|
// 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")]
|
#[stable(feature = "process", since = "1.0.0")]
|
||||||
pub struct ExitStatus(imp::ExitStatus);
|
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);
|
pub struct ExitStatus(i64);
|
||||||
|
|
||||||
impl ExitStatus {
|
impl ExitStatus {
|
||||||
|
@ -800,7 +800,7 @@ impl Process {
|
|||||||
//
|
//
|
||||||
// This is not actually an "exit status" in Unix terminology. Rather, it is a "wait status".
|
// 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`.
|
// 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);
|
pub struct ExitStatus(c_int);
|
||||||
|
|
||||||
impl fmt::Debug for ExitStatus {
|
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);
|
pub struct ExitStatus(c_int);
|
||||||
|
|
||||||
impl ExitStatus {
|
impl ExitStatus {
|
||||||
|
@ -179,7 +179,7 @@ impl Process {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Unix exit statuses
|
/// Unix exit statuses
|
||||||
#[derive(PartialEq, Eq, Clone, Copy, Debug)]
|
#[derive(PartialEq, Eq, Clone, Copy, Debug, Default)]
|
||||||
pub struct ExitStatus(c_int);
|
pub struct ExitStatus(c_int);
|
||||||
|
|
||||||
impl ExitStatus {
|
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 {
|
impl ExitStatus {
|
||||||
pub fn exit_ok(&self) -> Result<(), ExitStatusError> {
|
pub fn exit_ok(&self) -> Result<(), ExitStatusError> {
|
||||||
self.0
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn code(&self) -> Option<i32> {
|
pub fn code(&self) -> Option<i32> {
|
||||||
self.0
|
Some(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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for ExitStatus {
|
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 {
|
fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
self.0
|
self.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Clone, Copy, Debug)]
|
|
||||||
pub struct ExitStatusError(ExitStatus);
|
|
||||||
|
|
||||||
impl Into<ExitStatus> for ExitStatusError {
|
impl Into<ExitStatus> for ExitStatusError {
|
||||||
fn into(self) -> ExitStatus {
|
fn into(self) -> ExitStatus {
|
||||||
self.0.0
|
self.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ExitStatusError {
|
impl ExitStatusError {
|
||||||
pub fn code(self) -> Option<NonZeroI32> {
|
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);
|
pub struct ExitStatus(c::DWORD);
|
||||||
|
|
||||||
impl ExitStatus {
|
impl ExitStatus {
|
||||||
|
Loading…
Reference in New Issue
Block a user