Skip to content

Document trailing self in paths#2237

Open
traviscross wants to merge 1 commit intomasterfrom
TC/trailing-self-in-paths
Open

Document trailing self in paths#2237
traviscross wants to merge 1 commit intomasterfrom
TC/trailing-self-in-paths

Conversation

@traviscross
Copy link
Copy Markdown
Contributor

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

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.
@rustbot rustbot added the S-waiting-on-review Status: The marked PR is awaiting review from a maintainer label Apr 20, 2026
@traviscross traviscross added the S-waiting-on-stabilization Waiting for a stabilization PR to be merged in the main Rust repository label Apr 20, 2026
Copy link
Copy Markdown
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.

@traviscross traviscross removed the S-waiting-on-review Status: The marked PR is awaiting review from a maintainer label Apr 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-stabilization Waiting for a stabilization PR to be merged in the main Rust repository

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants