-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Stabilize main
with non-() return types
#48453
Comments
@rfcbot fcp merge I propose that we stabilize as described above. |
Team member @nikomatsakis has proposed to merge this. The next step is review by the rest of the tagged teams: Concerns:
Once a majority of reviewers approve (and none object), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
👍 to stabilizing the basics here. 👎 to some of the allowed return types. I would propose only stabilizing the following new return types:
Thoughts on the others:
I'll happily make a PR restricting things as above if that'd be helpful. |
@rfcbot concern delay stabilization of nesting and I feel basically the same way that @scottmcm does-- nesting (e.g. Edit: also |
Yeah it is the opposite, |
I noticed that there's |
The RFC says Should the RFC be amended to reflect this change, and to explain why Debug is the right choice? |
@ExpHP yes, you are correct. Something approaching a summary of thinking around |
I'm surprised by the concern about nesting - how would someone come to nest results in their main return anyway? It seems like the natural way to implement termination, which has the consequence of enabling this kind of thing, but that it happening in practice would be a non-issue.
we do not usually amend RFCs to cover changes before stabilization. they are design documents for implementation, they dont play any sort of 'constitutional' role. |
@withoutboats, that is interesting. If I'm understanding you correctly, by allowing Personally, I was only considering what to allow from the perspective of being conservative; but when being conservative mandates extra logic to specifically disallow certain types, I can see the problem. (Such a limitation could also feel quite arbitrary in blocking some scenario we might not be imagining at the moment...) Thanks, as usual, for the enlightening perspective. :) |
Fixed the wasm reference. I also thought we might want to limit the impls. Note that we have no mechanism for "feature-gating" impls, so the only way to limit things once we stabilize the basic concept is to remove the stuff we don't want. I think that supporting only the basics ( If we wanted to go crazy (I don't), I could imagine adding a new trait like |
good catch, I missed that |
@scottmcm if you prep the PR, I will update the description |
I think the alternative that @cramertj and @scottmcm would prefer is that we replace the Result impl with two impls:
Then its not all types that implement I wouldn't really mind doing this, but I think philosophically I'd tend to prefer an open system that allows for some confusing cases than a closed system. Having the open impl could allow for use cases involving third party types we haven't thought of. As an example, I could see some framework with a special type that implements Its sort of the nature of a type class based polymorphism system that we enable extensions we haven't anticipated, including possibly bad ones. I'd also draw a distinction between designs that make things that we don't like possible and designs that lead people into an outcome we don't like. Does anyone see a way that the current set of impls encourages users to do a nested Result? I don't. I think all of the impls that exist - including i32 and bool - are fine and good and should exist, but I also don't see the ones that people want removed actually being used very often, so I'd be fine removing them to make progress on the impls that people very clearly want. |
@withoutboats ah, I somehow misread and thought that you had registered the concern (but I see now it was @cramertj). I think I feel the same as you -- I found the nesting a bit odd but probably better on balance than The Right Thing of having more traits, and not necessarily bad. Also, the design I mentioned is a bit busted, because any design that allows the nested type to specify the exit code means it can specify a non-zero error code, which is traditionally an error result (but not necessarily, there is no fixed interpretation; I mean consider a command intended to be used within the bash Anyway, I also just kind of don't care that much. I'm happy to start with a simple set of impls. I'm also happy to start with a more expansive set. |
Ah, I understand the desire for nesting now if the goal was to reduce the number of traits involved. It seems unlikely that someone would write I still feel fairly strongly that |
PR up at #48497, with impls as boats guessed. I added an unstable please-don't-rely-on-this-at-all I'm definitely not saying we'll never re-broaden these impls, but I like stabilizing just the obviously valuable cases now and seeing what comes up, like rust-lang/rfcs#1937 (comment) |
@cramertj care to resolve your concern? |
@rfcbot resolved delay stabilization of nesting and @nikomatsakis Thanks! Just saw the r+ on @scottmcm's PR. |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
…n, r=nikomatsakis Restrict the Termination impls to simplify stabilization Make a minimal commitment in preparation for stabilization. More impls, or broader ones, are likely in future, but are not necessary at this time and are more controversial. cc rust-lang#48453 (comment) r? @nikomatsakis
…crichton Better docs and associated SUCCESS/FAILURE for process::ExitCode Follow-up to rust-lang#48497 (comment), since that PR was the minimal thing to unblock rust-lang#48453 (comment). r? @nikomatsakis
The final comment period is now complete. |
I added #48854 to propose stabilizing unit tests that return results. |
All right, let's do this! Here are some mentoring instructions for preparing a stabilization PR. The general instructions for stabilization can be found on forge. We are stabilizing the Technically, that stabilizes more than is described here, because it will also stabilize using non- UPDATE: OK, looks like we may want to split the feature gates after all. See here for further mentoring instructions. |
cc #48890 for an ICE in this feature |
OK, it seems like I was wrong about #48854, perhaps we will wait to stabilize that feature. That means that the stabilization PR for this feature is going to need to do two things:
To do the first part (separation) will involve the following steps:
https://github.com/rust-lang/rust/blob/master/src/libsyntax/test.rs#L334 https://github.com/rust-lang/rust/blob/master/src/libsyntax/test.rs#L361 https://github.com/rust-lang/rust/blob/master/src/libsyntax/test.rs#L390 https://github.com/rust-lang/rust/blob/master/src/libsyntax/test.rs#L418 There may be a few other places, not sure. |
This stabilizes `main` with non-() return types; see rust-lang#48453.
…, r=nikomatsakis Stabilize termination_trait, split out termination_trait_test For rust-lang#48453. First time contribution, so I'd really appreciate any feedback on how this PR can be better. Not sure exactly what kind of documentation update is needed. If there is no PR to update the reference, I can try doing that this week as I have time.
…, r=nikomatsakis Stabilize termination_trait, split out termination_trait_test For rust-lang#48453. First time contribution, so I'd really appreciate any feedback on how this PR can be better. Not sure exactly what kind of documentation update is needed. If there is no PR to update the reference, I can try doing that this week as I have time.
…, r=nikomatsakis Stabilize termination_trait, split out termination_trait_test For rust-lang#48453. First time contribution, so I'd really appreciate any feedback on how this PR can be better. Not sure exactly what kind of documentation update is needed. If there is no PR to update the reference, I can try doing that this week as I have time.
…, r=nikomatsakis Stabilize termination_trait, split out termination_trait_test For rust-lang#48453. First time contribution, so I'd really appreciate any feedback on how this PR can be better. Not sure exactly what kind of documentation update is needed. If there is no PR to update the reference, I can try doing that this week as I have time.
This stabilization happened; closing. |
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 permitsmain
to have a return type other than()
. This return type must implement theTermination
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)fn main() -> Result<(), E>
whereE: Debug
Err
, aDebug
printout occursfn main() -> Result<!, E>
whereE: Debug
The changes from the RFC are as follows:
Result
impl to useDebug
The following unresolved questions will be resolved:
libc::EXIT_SUCCESS
for "Ok" andlibc::EXIT_FAILURE
for "Err"But the following is not stabilized and free to change:
Termination
trait and its methodsstd::process::Termination
-> Result<...>
in unit tests (not yet landed)ErrCode
newtype wrapper for returning a custom error code--
UPDATE 1: Restricted the set of termination impls as proposed by @scottmcm in #48497.
The text was updated successfully, but these errors were encountered: