]> git.lizzy.rs Git - rust.git/commit - src/tools/rust-analyzer
Rollup merge of #93840 - yaahc:termination-stabilization-celebration-station, r=josht...
authorDylan DPC <99973273+Dylan-DPC@users.noreply.github.com>
Tue, 29 Mar 2022 20:46:31 +0000 (22:46 +0200)
committerGitHub <noreply@github.com>
Tue, 29 Mar 2022 20:46:31 +0000 (22:46 +0200)
commitbba2a64d0c5ba20c4153676a09381b8703c197ba
treee145ce740ec6ed12a15660b3506fb84de6ff3718
parent5e1d19d30723c287f049662474021f2b9a9894ce
parent97c58e8a87b0218a54dd0d58df03ffbc6d7fa10c
Rollup merge of #93840 - yaahc:termination-stabilization-celebration-station, r=joshtriplett

Stabilize Termination and ExitCode

From https://github.com/rust-lang/rust/issues/43301

This PR stabilizes the Termination trait and associated ExitCode type. It also adjusts the ExitCode feature flag to replace the placeholder flag with a more permanent name, as well as splitting off the `to_i32` method behind its own permanently unstable feature flag.

This PR stabilizes the termination trait with the following signature:

```rust
pub trait Termination {
    fn report(self) -> ExitCode;
}
```

The existing impls of `Termination` are effectively already stable due to the prior stabilization of `?` in main.

This PR also stabilizes the following APIs on exit code

```rust
#[derive(Clone, Copy, Debug)]
pub struct ExitCode(_);

impl ExitCode {
    pub const SUCCESS: ExitCode;
    pub const FAILURE: ExitCode;
}

impl From<u8> for ExitCode { /* ... */ }
```

---

All of the previous blockers have been resolved. The main ones that were resolved recently are:

* The trait's name: We decided against changing this since none of the alternatives seemed particularly compelling. Instead we decided to end the bikeshedding and stick with the current name. ([link to the discussion](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Termination.2FExit.20Status.20Stabilization/near/269793887))
* Issues around platform specific representations: We resolved this issue by changing the return type of `report` from `i32` to the opaque type `ExitCode`. That way we can change the underlying representation without affecting the API, letting us offer full support for platform specific exit code APIs in the future.
* Custom exit codes: We resolved this by adding `From<u8> for ExitCode`. We choose to only support u8 initially because it is the least common denominator between the sets of exit codes supported by our current platforms. In the future we anticipate adding platform specific extension traits to ExitCode for constructors from larger or negative numbers, as needed.
library/std/src/process.rs
library/test/src/lib.rs