-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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 never_type *again* #57012
Comments
@rfcbot fcp merge c'mon, rfcbot! |
Team member @cramertj has proposed to merge this. The next step is review by the rest of the tagged team members:
Concerns:
Once a majority of reviewers approve (and at most 2 approvals are outstanding), 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. |
@rfcbot concern impls The remaining unchecked checkbox in the description of #35121 is:
Stabilizing If it is, let’s discuss it in this issue. Currently in https://doc.rust-lang.org/nightly/std/primitive.never.html we have: impl Hash for !
impl Copy for !
impl Debug for !
impl Clone for !
impl PartialOrd<!> for !
impl Ord for !
impl Eq for !
impl PartialEq<!> for !
impl Display for !
impl Error for !
impl Termination for ! @rust-lang/libs, anything to add? |
@SimonSapin it's not a breaking change AFAIK, so we can add them over time. I'm not sure if we should implement traits for |
@rfcbot concern fallback In addition to reverting the stabilization, #50121 also reverted “to the previous fallback semantics (i.e. it is once again dependent on whether the crate has opted into As far as I understand, this is about type inference of a diverging expression like When it previously landed in Nightly, we found out #35121 (comment) that the fallback change could cause some previously-valid code to not compile anymore: #48950 (comment), and some (other) previously-valid |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
for<E> E: From<!> Is nice for error handling, but I recall there are orphan/overlapping issues adding it later. I think this is because that impl is technically an overlapping impl with |
@Ericson2314 I agree that Adding "some hack" to bend the language rules and somehow allow both these impls (picking an arbitrary one to "win" is ok, since they behave the same at the intersection) has been discussed before in the abstract, but there has never been a concrete proposal. Concretely, this would need:
Without all of these things soon, I suspect that consensus would be to give up on |
Noting so I/we remember from this week's T-lang meeting: @rfcbot concern fundamental-and-fn-traits We had some discussion around @rfcbot concern more-elaborate-report It would be nice to have all the behavior changes more clearly specified in one place before we stabilize so it's clear what is being stabilized. @rfcbot concern from-impl Noting this as a concern temporarily until conversation has resolved itself. |
I meant to add: in #35121 (comment) we discussed only making the fallback change in a new edition. We missed the 2018 train, so this would be for 2021 (or whenever we’ll make the next one). Also, in the #48950 (comment) case, fallback occurred in the expansion of a |
I don't know whether this would actually be easier to implement than the "some hack" itself which would allow the To try to avoid confusion I'll call the (hypothetical) hack which allows Even if it's not easier to implement, the future-proofing hack requires fewer commitments -- we don't have to commit to the |
But the future-proofing hack blocks a useful use case. For the same reason that |
Yes, which is why it's good that we can choose to revert it at any time. |
An alternative in the future would be to add the impl but ignore coherence completely for any |
I like the idea of tweaking coherence not with a special case for a particular pair of impls but with a rule about allowing overlap when the intersection only has unreachable functions. There is somewhat similar precedent in https://rust-lang.github.io/rfcs/1268-allow-overlapping-impls-on-marker-traits.html, although like in that case we might want to make it opt-in. |
TL;DR: We shouldn't implement the |
@SimonSapin I really like that idea! We could use the same logic that deduces there is only one possible impl to also allow elliding the trait items: impl<T> From<!> for T; |
@rfcbot resolve impls @cramertj How do you feel about making this issue explicitly not propose any change to type inference fallback from |
I believe this would be compatible to add later, after the never type is stabilized. And so this doesn’t need to block this FCP. @Centril, does this resolve your |
@SimonSapin ah so to be clear, if we have |
This comment has been minimized.
This comment has been minimized.
Since discussion seems to have stalled, I’ll try to summarize the remaining concerns.
|
Nominating for discussion in lang-team meeting to try and get "unstuck". We discussed a bit today. I think we generally agreed that, with respect to the second question at least, an appealing option would be to extend coherence so that it was treated "as if" such an impl existed, without actually having the impl. That would require some careful coding, though, from what I can tell. It would certainly be easier to just allow this impl to "opt out" from coherence rules -- I wonder what it would take to convince ourselves that specialization will allow the impl. (It seems very likely to me that it would, but I've not given deep thought to it.) Regarding the fallback, there is definitely a "core disagreement" here between (a) missing an opportunity to have the "right" fallback and (b) affecting existing code. I am curious about the "mitigations" option -- @SimonSapin are you thinking of something like a lint? |
We did not have any time to discuss the issue this week on the language team meeting; rescheduling for next week instead. |
Postponing until a future meeting. |
@Centril Are there any news on |
@dnrusakov Still the same as before; see #57012 (comment) and #57012 (comment). I think the main blocker now is the future proofing some sort of perma-unstable reservation hack. I'm not familiar with those parts of the compiler to do that, but maybe @eddyb or @arielb1 can. |
reserve `impl<T> From<!> for T` this is necessary for never-type stabilization. cc #57012 #35121 I think we wanted a crater run for this @nikomatsakis? r? @nikomatsakis
How useful / necessary is the trait impl? Conversion from |
I re-read everything and I get it now - avoiding problems from |
reserve `impl<T> From<!> for T` this is necessary for never-type stabilization. cc rust-lang#57012 rust-lang#35121 I think we wanted a crater run for this @nikomatsakis? r? @nikomatsakis
reserve `impl<T> From<!> for T` this is necessary for never-type stabilization. cc rust-lang#57012 rust-lang#35121 I think we wanted a crater run for this @nikomatsakis? r? @nikomatsakis
reserve `impl<T> From<!> for T` this is necessary for never-type stabilization. cc rust-lang#57012 rust-lang#35121 I think we wanted a crater run for this @nikomatsakis? r? @nikomatsakis
reserve `impl<T> From<!> for T` this is necessary for never-type stabilization. cc #57012 #35121 I think we wanted a crater run for this @nikomatsakis? r? @nikomatsakis
@Centril proposal cancelled. |
#49593 has now been fixed. This was the reason for the previous revert of stabilization (#50121). Previous stabilization report is [here]. Let's try this again!
@rfcbot fcp merge
cc #35121
(pnkfelix notes :the previous issue discussing stabilization of
!
was #48950; its possible the[here]
above was supposed to link to that...)The text was updated successfully, but these errors were encountered: