Implement RFC 2338, "Type alias enum variants"#56225
Conversation
|
The tricky part of handling type parameters is still to be done, but basic cases are working already. Any advice on this expanding on your previous comment would be appreciated, @petrochenkov. (Hope you don't mind I r?ed you, as well.) |
This comment has been minimized.
This comment has been minimized.
|
Everything about generic arguments should be in |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Big push coming up... I should be able to finish this tomorrow. |
|
Ready for review now, @petrochenkov. :-) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Awesome that you managed to implement this! I'm still a bit concerned about the handling of type arguments, since the implementation now diverges from the very explicit decision made in the RFC. @petrochenkov registered his concern then, too, but I'm surprised that the implementation now diverges from the spec as laid down in the RFC. |
|
@djc I believe the RFC as accepted is generally unimplementable, it seems that was an oversight during accepting it. EDIT: to expand a bit on that: That means that if type parameters are involved, At the point where you can introduce any new semantics, you already have a type with its parameters applied, and all you can do is use them in conjunction with the variant. Unless you want to allow parameters to be specified twice, you can't allow parameters on the variant as well. I believe this problem with the RFC might've resulted from missing the fact that |
…tiate_value_path`.
This comment has been minimized.
This comment has been minimized.
|
@bors r+ |
|
📌 Commit a4fa7ef has been approved by |
|
Thanks for helping get this past the post, @petrochenkov. :-) |
|
☀️ Test successful - status-appveyor, status-travis |
|
📣 Toolstate changed by #56225! Tested on commit 5918318. 💔 clippy-driver on windows: test-pass → build-fail (cc @Manishearth @llogiq @mcarton @oli-obk, @rust-lang/infra). |
This PR implements RFC 2338, allowing one to write code like the following.
Since
Selfcan be considered a type alias in this context, it also enables usingSelf::Variantas both a constructor and pattern.Fixes issues #56199 and #56611.
N.B., after discussing the syntax for type arguments on enum variants with @petrochenkov and @eddyb (there are also a few comments on the tracking issue), the consensus seems to be treat the syntax as follows, which ought to be backwards-compatible.
I do not know if this will need an FCP, but let's start one if so.