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
Contributor

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
@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
Contributor 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
Contributor 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
Contributor 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

I-lang-nominated Nominated for discussion during a lang team meeting. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants