Skip to content

fix: preserve comments around associated type bounds - #7014

Open
saberoueslati wants to merge 1 commit into
rust-lang:mainfrom
saberoueslati:fix/issue-6761-associated-type-bounds
Open

fix: preserve comments around associated type bounds#7014
saberoueslati wants to merge 1 commit into
rust-lang:mainfrom
saberoueslati:fix/issue-6761-associated-type-bounds

Conversation

@saberoueslati

Copy link
Copy Markdown

Summary

Fixes #6761, where rustfmt could duplicate associated-type bounds when comments appeared inside the bounds and before a where clause.

The rewrite now:

  • Uses the final bound’s span when recovering comments before where.
  • Preserves comments before and after the :.
  • Retains the existing behavior for associated types without bounds.

Added regression coverage for comments inside bounds, around the colon, before where, and on generic associated types.

Testing

  • cargo test --lib system_tests

@rustbot rustbot added the S-waiting-on-review Status: awaiting review from the assignee but also interested parties. label Aug 6, 2026
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.

Rustfmt generates invalid code for associated type bounds with where-clause and comments

2 participants