Skip to content

Prevent duplicating comments and tokens when rewriting trait headers#6834

Open
ytmimi wants to merge 8 commits intorust-lang:mainfrom
ytmimi:issue_6160
Open

Prevent duplicating comments and tokens when rewriting trait headers#6834
ytmimi wants to merge 8 commits intorust-lang:mainfrom
ytmimi:issue_6160

Conversation

@ytmimi
Copy link
Contributor

@ytmimi ytmimi commented Mar 20, 2026

Fixes #6160, Fixes #5841

Expand the HeaderPart struct to handle some new header parts like, const, unsafe, and auto and refactor trait header formatting to use HeaderPart.

r? @fee1-dead since you originally added HeaderPart

@rustbot rustbot added the S-waiting-on-review Status: awaiting review from the assignee but also interested parties. label Mar 20, 2026
ytmimi added 8 commits March 20, 2026 17:24
Helper method to get the `Span` of a known substring within a span.
Simplify macro header formatting by using the new `HeaderPart::keyword`
associated function.
Keep track of the `lo` span when rewriting parts the header so that we
can correctly recover comments between the last rewritten part of the
trait definition and the body of the trait.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Comment in trait visibility position causes token duplication Rustfmt is … confused 😳 by // comment after pub and before trait

3 participants