Skip to content

Commit 2d213f7

Browse files
committed
Make ExitStatus an inhabited type on all platforms
Even where actually running processes is not supported. Needed for the next commit. The manual trait implementations now belong on ExitStatusError, which still can't exist.
1 parent b435960 commit 2d213f7

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

library/std/src/sys/unsupported/process.rs

+19-18
Original file line numberDiff line numberDiff line change
@@ -99,58 +99,59 @@ impl fmt::Debug for Command {
9999
}
100100
}
101101

102-
pub struct ExitStatus(!);
102+
#[derive(PartialEq, Eq, Clone, Copy, Debug)]
103+
#[non_exhaustive]
104+
pub struct ExitStatus();
103105

104106
impl ExitStatus {
105107
pub fn exit_ok(&self) -> Result<(), ExitStatusError> {
106-
self.0
108+
Ok(())
107109
}
108110

109111
pub fn code(&self) -> Option<i32> {
110-
self.0
112+
Some(0)
111113
}
112114
}
113115

114-
impl Clone for ExitStatus {
115-
fn clone(&self) -> ExitStatus {
116-
self.0
116+
impl fmt::Display for ExitStatus {
117+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
118+
write!(f, "<dummy exit status>")
117119
}
118120
}
119121

120-
impl Copy for ExitStatus {}
122+
pub struct ExitStatusError(!);
121123

122-
impl PartialEq for ExitStatus {
123-
fn eq(&self, _other: &ExitStatus) -> bool {
124+
impl Clone for ExitStatusError {
125+
fn clone(&self) -> ExitStatusError {
124126
self.0
125127
}
126128
}
127129

128-
impl Eq for ExitStatus {}
130+
impl Copy for ExitStatusError {}
129131

130-
impl fmt::Debug for ExitStatus {
131-
fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
132+
impl PartialEq for ExitStatusError {
133+
fn eq(&self, _other: &ExitStatusError) -> bool {
132134
self.0
133135
}
134136
}
135137

136-
impl fmt::Display for ExitStatus {
138+
impl Eq for ExitStatusError {}
139+
140+
impl fmt::Debug for ExitStatusError {
137141
fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
138142
self.0
139143
}
140144
}
141145

142-
#[derive(PartialEq, Eq, Clone, Copy, Debug)]
143-
pub struct ExitStatusError(ExitStatus);
144-
145146
impl Into<ExitStatus> for ExitStatusError {
146147
fn into(self) -> ExitStatus {
147-
self.0.0
148+
self.0
148149
}
149150
}
150151

151152
impl ExitStatusError {
152153
pub fn code(self) -> Option<NonZeroI32> {
153-
self.0.0
154+
self.0
154155
}
155156
}
156157

0 commit comments

Comments
 (0)