Closed
Description
This is a sub-issue of the larger tracking issue devoted to the ?
in main RFC. It is specifically proposing that we stabilize the behavior that permits main
to have a return type other than ()
. This return type must implement the Termination
trait. The details of the trait itself (including its name and so forth) are not stabilized.
This commits us to the following (each link is to a test):
fn main() -> i32
fn main() -> !
(no test, but here is the impl -- a test is being added in Termination trait in tests #48143)- should never return
fn main() -> Result<(), E>
whereE: Debug
- on
Err
, aDebug
printout occurs - these impls are modified in Restrict the Termination impls to simplify stabilization #48497
- on
fn main() -> Result<!, E>
whereE: Debug
- these impls are modified in Restrict the Termination impls to simplify stabilization #48497
The changes from the RFC are as follows:
- we modified the
Result
impl to useDebug
The following unresolved questions will be resolved:
- The precise initial implementations
- as above
- exit codes (discussion)
- these are defined as
libc::EXIT_SUCCESS
for "Ok" andlibc::EXIT_FAILURE
for "Err" - except for wasm, where they are currently defined as 0 or 1 for wasm -- this is because those constants are/were not available for wasm
- (they also appear not to be publicly exported? but that is not part of this stabilization)
- these are defined as
But the following is not stabilized and free to change:
- the name/location of the
Termination
trait and its methods- likely changing to
std::process::Termination
- likely changing to
- the usage of
-> Result<...>
in unit tests (not yet landed) - the
ErrCode
newtype wrapper for returning a custom error code
--
UPDATE 1: Restricted the set of termination impls as proposed by @scottmcm in #48497.
Metadata
Metadata
Assignees
Labels
Category: An issue proposing an enhancement or a PR with one.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Relevant to the language team, which will review and decide on the PR/issue.This issue / PR is in PFCP or FCP with a disposition to merge it.The final comment period is finished for this PR / Issue.