Skip to content
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

Update Termination trait docs #94486

Closed
wants to merge 1 commit into from
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
5 changes: 5 additions & 0 deletions library/std/src/process.rs
Original file line number Diff line number Diff line change
@@ -2030,6 +2030,11 @@ 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.
///
/// Note that this trait is supposed to be used in standard library runtime,
/// where returned value from main function is considered meaningful.
/// On the other hand, implementing Termination in no-std environment, where
/// there is no notion of `exit status`, has no effect or may possibly cause bugs.
Comment on lines +2036 to +2037
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue isn't that it could lead to bugs, std::process::Termination and std::process::exit wouldn't be available in a no_std binary so there would be no way to misuse it. I believe the issue that @Lokathor wanted to clarify was that Termination is intended to be a piece of the standard library's runtime that is provided for convenience and should not be seen as a general requirement on what other runtime implementations must do.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. My concern is not that implementing Termination is ever an error/bug. Instead, I would just like the docs to be clear that how the value is interpreted when it's returned from main is not something to rely on in alternative runtimes.

#[cfg_attr(not(test), lang = "termination")]
#[unstable(feature = "termination_trait_lib", issue = "43301")]
#[rustc_on_unimplemented(