Rollup merge of #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 #130532.

History: [IRLO thread](https://internals.rust-lang.org/t/mini-pre-rfc-redesigning-process-exitstatus/5426) (`ExitCode` as a `main` return), #48618 (initial impl), #93445 (`From<u8>` impl).
This commit is contained in:
Matthias Krüger 2024-09-19 20:37:08 +02:00 committed by GitHub
commit 553c20cc92
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -255,11 +255,11 @@ impl ExitStatusError {
} }
#[derive(PartialEq, Eq, Clone, Copy, Debug)] #[derive(PartialEq, Eq, Clone, Copy, Debug)]
pub struct ExitCode(bool); pub struct ExitCode(u8);
impl ExitCode { impl ExitCode {
pub const SUCCESS: ExitCode = ExitCode(false); pub const SUCCESS: ExitCode = ExitCode(0);
pub const FAILURE: ExitCode = ExitCode(true); pub const FAILURE: ExitCode = ExitCode(1);
pub fn as_i32(&self) -> i32 { pub fn as_i32(&self) -> i32 {
self.0 as i32 self.0 as i32
@ -268,10 +268,7 @@ impl ExitCode {
impl From<u8> for ExitCode { impl From<u8> for ExitCode {
fn from(code: u8) -> Self { fn from(code: u8) -> Self {
match code { Self(code)
0 => Self::SUCCESS,
1..=255 => Self::FAILURE,
}
} }
} }