GeezerVison is showing github.com — Document trailing `self` in paths by traviscross · Pull Request #2237 · rust-lang/reference
Conversation
The Reference says that self can only appear as the first segment of a path. Further, the use chapter describes {self} brace syntax as the way to bind the parent entity of a use path under its own name.
In rust-lang/rust#155137, we're relaxing these restrictions: self may now also appear as the last segment of a path (preceded by ::) as long as the preceding path resolves to a module, enumeration, or trait. In a use path, use P::self [as name] is equivalent to use P::{self [as name]}. In non-use paths, forms such as type Ty = P::self and pub(in P::self) are now accepted.
Let's update the Reference to reflect this.
cc @ehuss @mu001999
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
mu001999 reacted with thumbs up emoji
The Reference says that `self` can only appear as the first segment of
a path. Further, the `use` chapter describes `{self}` brace syntax as
the way to bind the parent entity of a `use` path under its own name.
In rust-lang/rust#155137, we're relaxing these restrictions: `self`
may now also appear as the last segment of a path (preceded by `::`)
as long as the preceding path resolves to a module, enumeration,
or trait. In a `use` path, `use P::self [as name]` is equivalent
to `use P::{self [as name]}`. In non-`use` paths, forms such as
`type Ty = P::self` and `pub(in P::self)` are now accepted.
Let's update the Reference to reflect this.
ehuss
left a comment
•
edited by rustbot
Loading
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
1 more reviewer
ehuss
ehuss approved these changes
Reviewers whose approvals may not affect merge requirements
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|