Skip to content

fix since field version for termination stabilization #95452

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions library/std/src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1705,25 +1705,25 @@ impl crate::error::Error for ExitStatusError {}
/// }
/// ```
#[derive(Clone, Copy, Debug)]
#[stable(feature = "process_exitcode", since = "1.60.0")]
#[stable(feature = "process_exitcode", since = "1.61.0")]
pub struct ExitCode(imp::ExitCode);

#[stable(feature = "process_exitcode", since = "1.60.0")]
#[stable(feature = "process_exitcode", since = "1.61.0")]
impl ExitCode {
/// The canonical `ExitCode` for successful termination on this platform.
///
/// Note that a `()`-returning `main` implicitly results in a successful
/// termination, so there's no need to return this from `main` unless
/// you're also returning other possible codes.
#[stable(feature = "process_exitcode", since = "1.60.0")]
#[stable(feature = "process_exitcode", since = "1.61.0")]
pub const SUCCESS: ExitCode = ExitCode(imp::ExitCode::SUCCESS);

/// The canonical `ExitCode` for unsuccessful termination on this platform.
///
/// If you're only returning this and `SUCCESS` from `main`, consider
/// instead returning `Err(_)` and `Ok(())` respectively, which will
/// return the same codes (but will also `eprintln!` the error).
#[stable(feature = "process_exitcode", since = "1.60.0")]
#[stable(feature = "process_exitcode", since = "1.61.0")]
pub const FAILURE: ExitCode = ExitCode(imp::ExitCode::FAILURE);
}

Expand All @@ -1747,7 +1747,7 @@ impl ExitCode {
}
}

#[stable(feature = "process_exitcode", since = "1.60.0")]
#[stable(feature = "process_exitcode", since = "1.61.0")]
impl From<u8> for ExitCode {
/// Construct an `ExitCode` from an arbitrary u8 value.
fn from(code: u8) -> Self {
Expand Down Expand Up @@ -2092,27 +2092,27 @@ pub fn id() -> u32 {
/// standard library's runtime for convenience. Other runtimes are not required
/// to provide similar functionality.
#[cfg_attr(not(test), lang = "termination")]
#[stable(feature = "termination_trait_lib", since = "1.60.0")]
#[stable(feature = "termination_trait_lib", since = "1.61.0")]
#[rustc_on_unimplemented(
message = "`main` has invalid return type `{Self}`",
label = "`main` can only return types that implement `{Termination}`"
)]
pub trait Termination {
/// Is called to get the representation of the value as status code.
/// This status code is returned to the operating system.
#[stable(feature = "termination_trait_lib", since = "1.60.0")]
#[stable(feature = "termination_trait_lib", since = "1.61.0")]
fn report(self) -> ExitCode;
}

#[stable(feature = "termination_trait_lib", since = "1.60.0")]
#[stable(feature = "termination_trait_lib", since = "1.61.0")]
impl Termination for () {
#[inline]
fn report(self) -> ExitCode {
ExitCode::SUCCESS.report()
}
}

#[stable(feature = "termination_trait_lib", since = "1.60.0")]
#[stable(feature = "termination_trait_lib", since = "1.61.0")]
impl<E: fmt::Debug> Termination for Result<(), E> {
fn report(self) -> ExitCode {
match self {
Expand All @@ -2122,14 +2122,14 @@ impl<E: fmt::Debug> Termination for Result<(), E> {
}
}

#[stable(feature = "termination_trait_lib", since = "1.60.0")]
#[stable(feature = "termination_trait_lib", since = "1.61.0")]
impl Termination for ! {
fn report(self) -> ExitCode {
self
}
}

#[stable(feature = "termination_trait_lib", since = "1.60.0")]
#[stable(feature = "termination_trait_lib", since = "1.61.0")]
impl<E: fmt::Debug> Termination for Result<!, E> {
fn report(self) -> ExitCode {
let Err(err) = self;
Expand All @@ -2138,15 +2138,15 @@ impl<E: fmt::Debug> Termination for Result<!, E> {
}
}

#[stable(feature = "termination_trait_lib", since = "1.60.0")]
#[stable(feature = "termination_trait_lib", since = "1.61.0")]
impl<E: fmt::Debug> Termination for Result<Infallible, E> {
fn report(self) -> ExitCode {
let Err(err) = self;
Err::<!, _>(err).report()
}
}

#[stable(feature = "termination_trait_lib", since = "1.60.0")]
#[stable(feature = "termination_trait_lib", since = "1.61.0")]
impl Termination for ExitCode {
#[inline]
fn report(self) -> ExitCode {
Expand Down