GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Document trailing `self` in paths by traviscross · Pull Request #2237 · rust-lang/reference

Conversation

@traviscross

@traviscross traviscross commented Apr 20, 2026

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mu001999 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@traviscross
Document trailing self in paths
cf92e58
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
@traviscross traviscross mentioned this pull request Apr 20, 2026
Allow trailing self in more contexts rust-lang/rust#155137
Merged
ehuss
ehuss approved these changes Apr 21, 2026
View reviewed changes

@ehuss ehuss left a comment •
edited by rustbot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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.

Thanks!

View changes since this review

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@traviscross traviscross removed the S-waiting-on-review Status: The marked PR is awaiting review from a maintainer label Apr 22, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Apr 27, 2026
@JonathanBrouwer
Rollup merge of rust-lang#155137 - mu001999-contrib:self-at-end, r=pe…
8511605
…trochenkov

Allow trailing `self` in more contexts

Reference PR:

- rust-lang/reference#2237

As a follow-up PR to rust-lang#152996, after this PR:
1. Trailing `self` can appear in paths
2. [E0429](https://doc.rust-lang.org/stable/error_codes/E0429.html#error-code-e0429) will be no longer emitted, `use ...::self [as target];` will be equivalent to `use ...::{self [as target]};`

r? petrochenkov
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Apr 27, 2026
@JonathanBrouwer
Rollup merge of rust-lang#155137 - mu001999-contrib:self-at-end, r=pe…
56c2ab6
…trochenkov

Allow trailing `self` in more contexts

Reference PR:

- rust-lang/reference#2237

As a follow-up PR to rust-lang#152996, after this PR:
1. Trailing `self` can appear in paths
2. [E0429](https://doc.rust-lang.org/stable/error_codes/E0429.html#error-code-e0429) will be no longer emitted, `use ...::self [as target];` will be equivalent to `use ...::{self [as target]};`

r? petrochenkov
rust-timer added a commit to rust-lang/rust that referenced this pull request Apr 28, 2026
@rust-timer
Unrolled build for #155137
b1b06b8
Rollup merge of #155137 - mu001999-contrib:self-at-end, r=petrochenkov

Allow trailing `self` in more contexts

Reference PR:

- rust-lang/reference#2237

As a follow-up PR to #152996, after this PR:
1. Trailing `self` can appear in paths
2. [E0429](https://doc.rust-lang.org/stable/error_codes/E0429.html#error-code-e0429) will be no longer emitted, `use ...::self [as target];` will be equivalent to `use ...::{self [as target]};`

r? petrochenkov
@ehuss
ehuss enabled auto-merge April 30, 2026 02:40
@ehuss
ehuss added this pull request to the merge queue Apr 30, 2026
Merged via the queue into master with commit 581920f Apr 30, 2026
10 of 12 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@rustbot rustbot mentioned this pull request May 4, 2026
Update books rust-lang/rust#156152
Merged
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request May 4, 2026
@JonathanBrouwer
Rollup merge of rust-lang#156152 - rustbot:docs-update, r=ehuss
c966c2b
Update books

## rust-lang/reference

4 commits in 8c88f9d0bdd75ffdc0691676d83212ae22a18cee..581920f9109f141b88b860b3e1e8359e3896a150
2026-04-30 02:40:57 UTC to 2026-04-28 16:48:51 UTC

- Document trailing `self` in paths (rust-lang/reference#2237)
- add trailing comma (to follow style guidelines) (rust-lang/reference#2244)
- Doc: Add the LoongArch stabilized target features (rust-lang/reference#2217)
- typo (rust-lang/reference#2241)
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request May 5, 2026
@GuillaumeGomez
Rollup merge of rust-lang#156152 - rustbot:docs-update, r=ehuss
6c37722
Update books

## rust-lang/reference

4 commits in 8c88f9d0bdd75ffdc0691676d83212ae22a18cee..581920f9109f141b88b860b3e1e8359e3896a150
2026-04-30 02:40:57 UTC to 2026-04-28 16:48:51 UTC

- Document trailing `self` in paths (rust-lang/reference#2237)
- add trailing comma (to follow style guidelines) (rust-lang/reference#2244)
- Doc: Add the LoongArch stabilized target features (rust-lang/reference#2217)
- typo (rust-lang/reference#2241)
rust-timer added a commit to rust-lang/rust that referenced this pull request May 5, 2026
@rust-timer
Unrolled build for #156152
049d1b1
Rollup merge of #156152 - rustbot:docs-update, r=ehuss

Update books

## rust-lang/reference

4 commits in 8c88f9d0bdd75ffdc0691676d83212ae22a18cee..581920f9109f141b88b860b3e1e8359e3896a150
2026-04-30 02:40:57 UTC to 2026-04-28 16:48:51 UTC

- Document trailing `self` in paths (rust-lang/reference#2237)
- add trailing comma (to follow style guidelines) (rust-lang/reference#2244)
- Doc: Add the LoongArch stabilized target features (rust-lang/reference#2217)
- typo (rust-lang/reference#2241)
@traviscross traviscross removed the S-waiting-on-stabilization Waiting for a stabilization PR to be merged in the main Rust repository label May 6, 2026
@ehuss ehuss added this to the 1.97.0 milestone Jun 16, 2026
@tshepang tshepang mentioned this pull request Jul 10, 2026
[1.97] FLS updates for 26.08 release ferrocene/ferrocene#2464
Merged
bors-ferrocene Bot added a commit to ferrocene/ferrocene that referenced this pull request Jul 13, 2026
@bors-ferrocene @kirtchev-adacore @tshepang
Merge #2464
2be0b3b
2464: [1.97] FLS updates for 26.08 release r=jyn514 a=tshepang

This is equivalent of #2333, and adds more fixes not in that PR, and, finally, updates path-related rules for `self` keyword (in a2884d7). That commit corresponds to rust-lang/reference#2237 and rust-lang/reference#2221.

Co-authored-by: bors-ferrocene[bot] <87868125+bors-ferrocene[bot]@users.noreply.github.com>
Co-authored-by: kirtchev-adacore <[email protected]>
Co-authored-by: Tshepang Mbambo <[email protected]>
Co-authored-by: Tshepang Mbambo <[email protected]>
bors-ferrocene Bot added a commit to ferrocene/ferrocene that referenced this pull request Jul 13, 2026
@bors-ferrocene @kirtchev-adacore @tshepang
Merge #2464
3e27c7b
2464: [1.97] FLS updates for 26.08 release r=jyn514 a=tshepang

This is equivalent of #2333, and adds more fixes not in that PR, and, finally, updates path-related rules for `self` keyword (in a2884d7). That commit corresponds to rust-lang/reference#2237 and rust-lang/reference#2221.

Co-authored-by: bors-ferrocene[bot] <87868125+bors-ferrocene[bot]@users.noreply.github.com>
Co-authored-by: kirtchev-adacore <[email protected]>
Co-authored-by: Tshepang Mbambo <[email protected]>
Co-authored-by: Tshepang Mbambo <[email protected]>
bors-ferrocene Bot added a commit to ferrocene/ferrocene that referenced this pull request Jul 13, 2026
@bors-ferrocene @kirtchev-adacore @tshepang
Merge #2464
dddf405
2464: [1.97] FLS updates for 26.08 release r=jyn514 a=tshepang

This is equivalent of #2333, and adds more fixes not in that PR, and, finally, updates path-related rules for `self` keyword (in a2884d7). That commit corresponds to rust-lang/reference#2237 and rust-lang/reference#2221.

Co-authored-by: bors-ferrocene[bot] <87868125+bors-ferrocene[bot]@users.noreply.github.com>
Co-authored-by: kirtchev-adacore <[email protected]>
Co-authored-by: Tshepang Mbambo <[email protected]>
Co-authored-by: Tshepang Mbambo <[email protected]>
bors-ferrocene Bot added a commit to ferrocene/ferrocene that referenced this pull request Jul 14, 2026
@bors-ferrocene @kirtchev-adacore @tshepang
Merge #2464
7ad2886
2464: [1.97] FLS updates for 26.08 release r=jyn514 a=tshepang

This is equivalent of #2333, and adds more fixes not in that PR, and, finally, updates path-related rules for `self` keyword (in a2884d7). That commit corresponds to rust-lang/reference#2237 and rust-lang/reference#2221.

Co-authored-by: bors-ferrocene[bot] <87868125+bors-ferrocene[bot]@users.noreply.github.com>
Co-authored-by: kirtchev-adacore <[email protected]>
Co-authored-by: Tshepang Mbambo <[email protected]>
Co-authored-by: Tshepang Mbambo <[email protected]>
@traviscross
traviscross deleted the TC/trailing-self-in-paths branch November 28, 2026 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer
@ehuss 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

Labels

None yet

Projects

None yet

Milestone

1.97.0

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@traviscross @ehuss @rustbot
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.