Skip to content

Stabilize termination_trait_lib #56791

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

Closed
Closed
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
13 changes: 7 additions & 6 deletions src/libstd/process.rs
Original file line number Diff line number Diff line change
@@ -1583,23 +1583,24 @@ pub fn id() -> u32 {
/// The default implementations are returning `libc::EXIT_SUCCESS` to indicate
/// a successful execution. In case of a failure, `libc::EXIT_FAILURE` is returned.
#[cfg_attr(not(test), lang = "termination")]
#[unstable(feature = "termination_trait_lib", issue = "43301")]
#[stable(feature = "termination_trait_lib", since = "1.33.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.33.0")]
fn report(self) -> i32;
}

#[unstable(feature = "termination_trait_lib", issue = "43301")]
#[stable(feature = "termination_trait_lib", since = "1.33.0")]
impl Termination for () {
#[inline]
fn report(self) -> i32 { ExitCode::SUCCESS.report() }
}

#[unstable(feature = "termination_trait_lib", issue = "43301")]
#[stable(feature = "termination_trait_lib", since = "1.33.0")]
impl<E: fmt::Debug> Termination for Result<(), E> {
fn report(self) -> i32 {
match self {
@@ -1609,12 +1610,12 @@ impl<E: fmt::Debug> Termination for Result<(), E> {
}
}

#[unstable(feature = "termination_trait_lib", issue = "43301")]
#[stable(feature = "termination_trait_lib", since = "1.33.0")]
impl Termination for ! {
fn report(self) -> i32 { self }
}

#[unstable(feature = "termination_trait_lib", issue = "43301")]
#[stable(feature = "termination_trait_lib", since = "1.33.0")]
impl<E: fmt::Debug> Termination for Result<!, E> {
fn report(self) -> i32 {
let Err(err) = self;
@@ -1623,7 +1624,7 @@ impl<E: fmt::Debug> Termination for Result<!, E> {
}
}

#[unstable(feature = "termination_trait_lib", issue = "43301")]
#[stable(feature = "termination_trait_lib", since = "1.33.0")]
impl Termination for ExitCode {
#[inline]
fn report(self) -> i32 {
1 change: 0 additions & 1 deletion src/libtest/lib.rs
Original file line number Diff line number Diff line change
@@ -39,7 +39,6 @@
#![feature(set_stdio)]
#![feature(panic_unwind)]
#![feature(staged_api)]
#![feature(termination_trait_lib)]
#![feature(test)]

extern crate getopts;
Original file line number Diff line number Diff line change
@@ -9,6 +9,5 @@
// except according to those terms.

// run-pass
#![feature(termination_trait_lib)]

fn main() -> impl std::process::Termination { }