fix(items): format comments after where using clause_shape budget - #7156
Merged
Merged
Conversation
Contributor
Author
|
Fixes #7148 |
Member
I think you meant another issue, since that's this PR's number 😉 |
Contributor
Author
|
Thanks, that's why i shouldn't rely on autocomplete. Fixed to #7148 |
ytmimi
requested changes
Oct 2, 2026
Collaborator
|
Reminder, once the PR becomes ready for a review, use |
Contributor
|
Removed the |
dbaileychess
force-pushed
the
fix-where-clause-comment-wrap
branch
from
October 2, 2026 18:40
3aff0b6 to
bf43b7b
Compare
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Contributor
Author
|
@rustbot ready |
This comment was marked as resolved.
This comment was marked as resolved.
dbaileychess
force-pushed
the
fix-where-clause-comment-wrap
branch
from
October 2, 2026 18:48
bf43b7b to
df2780a
Compare
This comment was marked as off-topic.
This comment was marked as off-topic.
ytmimi
requested changes
Oct 2, 2026
When formatting an item with a where clause, the budget before the where clause is throttled by the item header width. However, comments between the `where` keyword and the first predicate are indented on their own lines and should be formatted with the full clause budget (`clause_shape`) rather than the throttled budget. Pass `clause_shape` to `rewrite_comments_before_after_where` so that comments after `where` are not prematurely wrapped. Fixes rust-lang#7148.
dbaileychess
force-pushed
the
fix-where-clause-comment-wrap
branch
from
October 2, 2026 20:28
df2780a to
3297756
Compare
Contributor
Author
|
@rustbot ready |
ytmimi
approved these changes
Oct 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #7148
When formatting an item with a
whereclause, the budget before thewherekeyword is throttled by the item header width (e.g.,max_width - header_len).However, comments located between the
wherekeyword and the first predicate are indented on their own lines. They should be formatted using the full clause budget (clause_shape) rather than the throttled header budget.Prior to this fix, comments after
wherewere prematurely wrapped at an artificially narrow column budget derived from the header length.Added
tests/source/where-clause-comment-wrap.rsandtests/target/where-clause-comment-wrap.rs.- Verified that the unpatched binary fails by wrapping the comment at column ~59.
- Verified that the patched binary passes without unwanted line wraps.
No LLM was used in the generation of this PR.