mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
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:
commit
553c20cc92
@ -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,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user