Skip to content

Allow trailing self in more contexts#155137

Open
mu001999 wants to merge 5 commits intorust-lang:mainfrom
mu001999-contrib:self-at-end
Open

Allow trailing self in more contexts#155137
mu001999 wants to merge 5 commits intorust-lang:mainfrom
mu001999-contrib:self-at-end

Conversation

@mu001999
Copy link
Copy Markdown
Member

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

@rfcbot reviewed

1 similar comment
@joshtriplett
Copy link
Copy Markdown
Member

@rfcbot reviewed

@rust-rfcbot rust-rfcbot added final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. and removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. labels Apr 15, 2026
@rust-rfcbot
Copy link
Copy Markdown
Collaborator

🔔 This is now entering its final comment period, as per the review above. 🔔

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. final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. I-lang-radar Items that are on lang's radar and will need eventual work or consideration. S-waiting-on-t-lang Status: Awaiting decision from T-lang T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants