Skip to content

Commit 3394557

Browse files
authored
Rollup merge of rust-lang#130554 - ShE3py:unsupported-exitcode, r=Noratrieb
`pal::unsupported::process::ExitCode`: use an `u8` instead of a `bool` `ExitCode` should “represents the status code the current process can return to its parent under normal termination”, but is currently represented as a `bool` on unsupported platforms, making the `impl From<u8> for ExitCode` lossy. Fixes rust-lang#130532. History: [IRLO thread](https://internals.rust-lang.org/t/mini-pre-rfc-redesigning-process-exitstatus/5426) (`ExitCode` as a `main` return), rust-lang#48618 (initial impl), rust-lang#93445 (`From<u8>` impl).
2 parents 17b0e39 + 4ea6b82 commit 3394557

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

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

+4-7
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,11 @@ impl ExitStatusError {
255255
}
256256

257257
#[derive(PartialEq, Eq, Clone, Copy, Debug)]
258-
pub struct ExitCode(bool);
258+
pub struct ExitCode(u8);
259259

260260
impl ExitCode {
261-
pub const SUCCESS: ExitCode = ExitCode(false);
262-
pub const FAILURE: ExitCode = ExitCode(true);
261+
pub const SUCCESS: ExitCode = ExitCode(0);
262+
pub const FAILURE: ExitCode = ExitCode(1);
263263

264264
pub fn as_i32(&self) -> i32 {
265265
self.0 as i32
@@ -268,10 +268,7 @@ impl ExitCode {
268268

269269
impl From<u8> for ExitCode {
270270
fn from(code: u8) -> Self {
271-
match code {
272-
0 => Self::SUCCESS,
273-
1..=255 => Self::FAILURE,
274-
}
271+
Self(code)
275272
}
276273
}
277274

0 commit comments

Comments
 (0)