Skip to content
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

Document type_alias_enum_variants #631

Open
ehuss opened this issue Jul 5, 2019 · 4 comments
Open

Document type_alias_enum_variants #631

ehuss opened this issue Jul 5, 2019 · 4 comments
Labels
A-resolve Name resolution, paths, namespaces, preludes, etc. New Content Missing features or aspects of language not currently documented. RFC Stabilization Docs Documentation required for stabilizing a feature

Comments

@ehuss
Copy link
Contributor

ehuss commented Jul 5, 2019

Stabilized in: rust-lang/rust#61682
RFC (issue): rust-lang/rfcs#2218
Issue: rust-lang/rust#52118

There is a brief mention of this at the bottom of https://github.com/rust-lang-nursery/reference/blob/master/src/items/type-aliases.md that should be updated.
Example has been updated in #831.

@Centril were you planning to update this?

@ehuss ehuss added the Easy We believe this would not be difficult to actually fix label Jul 5, 2019
@Centril Centril added RFC Stabilization Docs Documentation required for stabilizing a feature Enhancement Improvement in a non-prose section of the book labels Jul 5, 2019
@Centril
Copy link
Contributor

Centril commented Jul 5, 2019

There is a brief mention of this at the bottom of https://github.com/rust-lang-nursery/reference/blob/master/src/items/type-aliases.md that should be updated.

I think this is the wrong place for the primary docs since it adds to the confusion around the misnomer that type_alias_enum_variants is. In other words, it is not about type aliases, but about type relative resolution to enum variants.

cc @eddyb @petrochenkov

What we should focus on is making sure the following is covered in some form:

Reference guide

In the value and type namespaces, type-relative resolution to an enum variant is permitted.
This applies to expressions and patterns alike.

  1. Type relative resolution

    • Let E denote an enum definition with variants V0 to Vn.

    • Let F denote a type expression normalizing to E with generic substitutions Si.

    • Then a path <F>::Vj may resolve, with highest priority, in the value and type namespaces, to the variant Vj.

  2. Desugaring to type-relative resolution (pre-existing on stable)

    • Let X be an associated item of G.

    • A path G::X is equivalent to <G<..>>::X where .. denotes as many inference variables as G needs if it is generic.

    • A path G::<A0, .., An>::X is equivalent to <G::<A0, .., An>>::X.

Note that while resolution in the type namespace to an enum variant is allowed, enum variants themselves are not types (rust-lang/rfcs#2593 would allow that).

@Centril
Copy link
Contributor

Centril commented Jul 5, 2019

@Centril were you planning to update this?

Yeah but it may take a while to get to... tho if someone wants to have a go at it that would be lovely.

@ehuss ehuss added the A-resolve Name resolution, paths, namespaces, preludes, etc. label Jul 5, 2019
@ehuss
Copy link
Contributor Author

ehuss commented Jul 5, 2019

Since name resolution is not documented, I think it may be a bit difficult or awkward to define this in an adequate way. My intent was just that the clause at the bottom of that page is now wrong, it should be updated (or maybe removed if we don't want to have it there).

If you want, we can just remove the note and make this a sub-task of #568.

@Centril
Copy link
Contributor

Centril commented Jul 5, 2019

If you want, we can just remove the note and make this a sub-task of #568.

Yes this seems like a decent interim solution, but we should keep this issue open as a sub-task of #568 then.

@Havvy Havvy added New Content Missing features or aspects of language not currently documented. and removed Easy We believe this would not be difficult to actually fix Enhancement Improvement in a non-prose section of the book labels Jul 6, 2019
@ehuss ehuss mentioned this issue Jun 25, 2021
29 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-resolve Name resolution, paths, namespaces, preludes, etc. New Content Missing features or aspects of language not currently documented. RFC Stabilization Docs Documentation required for stabilizing a feature
Projects
None yet
Development

No branches or pull requests

3 participants