-
-
Notifications
You must be signed in to change notification settings - Fork 15k
Stabilize main with non-() return types #48453
Copy link
Copy link
Closed
Labels
C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-langRelevant to the language teamRelevant to the language teamdisposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.This issue / PR is in PFCP or FCP with a disposition to merge it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.The final comment period is finished for this PR / Issue.
Milestone
Metadata
Metadata
Assignees
Labels
C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-langRelevant to the language teamRelevant to the language teamdisposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.This issue / PR is in PFCP or FCP with a disposition to merge it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.The final comment period is finished for this PR / Issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
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 permitsmainto have a return type other than(). This return type must implement theTerminationtrait. 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() -> i32fn main() -> !(no test, but here is the impl -- a test is being added in Termination trait in tests #48143)fn main() -> Result<(), E>whereE: DebugErr, aDebugprintout occursfn main() -> Result<!, E>whereE: DebugThe changes from the RFC are as follows:
Resultimpl to useDebugThe following unresolved questions will be resolved:
libc::EXIT_SUCCESSfor "Ok" andlibc::EXIT_FAILUREfor "Err"But the following is not stabilized and free to change:
Terminationtrait and its methodsstd::process::Termination-> Result<...>in unit tests (not yet landed)ErrCodenewtype wrapper for returning a custom error code--
UPDATE 1: Restricted the set of termination impls as proposed by @scottmcm in #48497.