Skip to content

Allow trailing self in more contexts#155137

Merged
rust-bors[bot] merged 5 commits intorust-lang:mainfrom
mu001999-contrib:self-at-end
Apr 28, 2026
Merged

Allow trailing self in more contexts#155137
rust-bors[bot] merged 5 commits intorust-lang:mainfrom
mu001999-contrib:self-at-end

Conversation

@mu001999
Copy link
Copy Markdown
Member

@mu001999 mu001999 commented Apr 11, 2026

Reference PR:

View all comments

As a follow-up PR to #152996, after this PR:

  1. Trailing self can appear in paths
  2. E0429 will be no longer emitted, use ...::self [as target]; will be equivalent to use ...::{self [as target]};

r? petrochenkov

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 11, 2026
Comment thread compiler/rustc_resolve/src/build_reduced_graph.rs
Comment thread compiler/rustc_resolve/src/ident.rs Outdated
@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 13, 2026
@mu001999
Copy link
Copy Markdown
Member Author

@rustbot review

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 13, 2026
@petrochenkov
Copy link
Copy Markdown
Contributor

@mu001999 could you write a change description for lang team for this PR, like in the previous PRs?
I'll nominate it once it's written and the other comments are addressed.
@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 13, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 13, 2026

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@mu001999
Copy link
Copy Markdown
Member Author

Description for lang team

This PR implements the last part of the lang team guidance from #146972 (comment).
It relaxes the rules to allow trailing self in more context.

Concretely, after this PR

  1. use foo::self [as bar]; would be accepted and is resolved the same way as use foo::{self [as bar]};, instead of being rejected with E0429.
  2. In non-import paths, trailing self would be accepted as well. This will make things like type E = path::to::Enum::self; and pub(in path::to::Mod::self) accepted.

And technically, this PR will not break existing code.

@mu001999
Copy link
Copy Markdown
Member Author

@rustbot review

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 13, 2026
@petrochenkov petrochenkov added S-waiting-on-t-lang Status: Awaiting decision from T-lang I-lang-nominated Nominated for discussion during a lang team meeting. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 14, 2026
@traviscross traviscross added P-lang-drag-1 Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang T-lang Relevant to the language team labels Apr 15, 2026
@traviscross
Copy link
Copy Markdown
Contributor

Makes sense to me. Thanks @mu001999 for pushing this along. Let's propose to do it.

@rfcbot fcp merge lang

@rust-rfcbot
Copy link
Copy Markdown
Collaborator

rust-rfcbot commented Apr 15, 2026

Team member @traviscross has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

cc @rust-lang/lang-advisors: FCP proposed for lang, please feel free to register concerns.
See this document for info about what commands tagged team members can give me.

@rust-rfcbot rust-rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Apr 15, 2026
@tmandry
Copy link
Copy Markdown
Member

tmandry commented Apr 15, 2026

@rfcbot reviewed

@traviscross traviscross added I-lang-radar Items that are on lang's radar and will need eventual work or consideration. and removed I-lang-nominated Nominated for discussion during a lang team meeting. P-lang-drag-1 Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang labels Apr 15, 2026
@rustbot

This comment has been minimized.

@rust-rfcbot rust-rfcbot added finished-final-comment-period The final comment period is finished for this PR / Issue. to-announce Announce this issue on triage meeting and removed final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. labels Apr 25, 2026
@rust-rfcbot
Copy link
Copy Markdown
Collaborator

The final comment period, with a disposition to merge, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

@mu001999 mu001999 added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-t-lang Status: Awaiting decision from T-lang labels Apr 26, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 27, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@rust-log-analyzer

This comment has been minimized.

@petrochenkov
Copy link
Copy Markdown
Contributor

@bors r+

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Apr 27, 2026

📌 Commit d93395c has been approved by petrochenkov

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 27, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Apr 27, 2026
…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-bors Bot pushed a commit that referenced this pull request Apr 27, 2026
…uwer

Rollup of 9 pull requests

Successful merges:

 - #155760 (Remove `AttributeLintKind`)
 - #154510 (Partially stabilize LoongArch target features)
 - #155137 (Allow trailing `self` in more contexts)
 - #155433 (Rip out rustc_layout_scalar_valid_range_* attribute support)
 - #155702 (Change `ItemKind::Trait` to a field variant.)
 - #154896 (Fix ICE: Scalar layout for non-primitive non-enum type unsafe binder)
 - #155675 (Disallow non_exhaustive structs and enums with non_exhaustive variants from implementing `ConstParamTy`)
 - #155874 (Avoid misleading closure return type note)
 - #155876 (CI: rfl: move job forward to Linux v7.1-rc1)
rust-bors Bot pushed a commit that referenced this pull request Apr 27, 2026
…uwer

Rollup of 8 pull requests

Successful merges:

 - #154510 (Partially stabilize LoongArch target features)
 - #155137 (Allow trailing `self` in more contexts)
 - #155513 (rustc_public: implement `Pattern` type)
 - #155702 (Change `ItemKind::Trait` to a field variant.)
 - #154896 (Fix ICE: Scalar layout for non-primitive non-enum type unsafe binder)
 - #155675 (Disallow non_exhaustive structs and enums with non_exhaustive variants from implementing `ConstParamTy`)
 - #155874 (Avoid misleading closure return type note)
 - #155876 (CI: rfl: move job forward to Linux v7.1-rc1)
@rust-bors rust-bors Bot merged commit 56c2ab6 into rust-lang:main Apr 28, 2026
11 checks passed
@rustbot rustbot added this to the 1.97.0 milestone Apr 28, 2026
rust-timer added a commit that referenced this pull request Apr 28, 2026
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
@mu001999 mu001999 deleted the self-at-end branch April 28, 2026 06:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. I-lang-radar Items that are on lang's radar and will need eventual work or consideration. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team to-announce Announce this issue on triage meeting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants