Skip to content

Improve documentation of struct expressions #1799

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

WaffleLapkin
Copy link
Member

@WaffleLapkin WaffleLapkin commented Apr 20, 2025

This compiles:

trait Tr { type T; }
impl<T> Tr for T { type T = T; }

struct Enum { Unit, Tuple() }

<Enum as Tr>::T::Unit; // OK
<Enum as Tr>::T::Tuple(); // OK

So qualified paths can be used when constructing tuple/unit variants. This PR documents that. (note that tuple/unit struct expressions aren't really a thing -- they are just calls/paths, so this doesn't necessarily change much, calls/paths already have correct docs)

Additionally I added more mentions of the fact that these expressions are the same for enums.

@rustbot rustbot added the S-waiting-on-review Status: The marked PR is awaiting review from a maintainer label Apr 20, 2025
Copy link
Contributor

@ehuss ehuss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

I opened #1802 to capture my thoughts on this in general, and to consider just removing all of this. (Not a blocker for this PR.) I've never been particularly comfortable with how this is presented.

Comment on lines 26 to 29
StructExprTuple ->
PathInExpression `(`
PathExpression `(`
( Expression (`,` Expression)* `,`? )?
`)`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe to simplify this further it can be StructExprTuple -> CallExpression

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: The marked PR is awaiting review from a maintainer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants