Support partially formatting method chains - #6862
Draft
randomPoison wants to merge 17 commits into
Draft
randomPoison wants to merge 17 commits into
randomPoison wants to merge 17 commits into
Conversation
Check the span of the chain against the selected lines to format. Only allow formatting the chain as a single line if the entire chain is covered by the selected range.
Collaborator
|
☔ The latest upstream changes (possibly #7124) made this pull request unmergeable. Please resolve the merge conflicts. |
randomPoison
marked this pull request as draft
September 21, 2026 22:11
Contributor
Author
|
I'm switching this to being a draft since I'd like to do another round of review on this before maintainers review it. This was the first non-trivial change I made in the repo and I'm much more familiar with rustfmt internals now, so I'd like to make sure everything looks good before taking maintainer time (especially in light of the new LLM usage policy). |
Contributor
Author
This branch has not been deployed
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.
Support formatting method chains when only part of the chain is selected with
--file-lines, ensuring that only the selected parts of the chain are modified. Partially addresses #4053.To support this I had to define how chains should be formatted when only part of the chain is selected, since short chains want to be formatted into a single line but we can't do so if only part of the chain was selected. I've opted to have partially-selected chains always be formatted as multi-line chains (i.e. one call in the chain per line, as is the case for long method chains), even if the chain as a whole would be short enough to fit in one line. This means we sometimes get different formatting when formatting the chain as a whole vs formatting only part of the chain, but that seems like the only reasonable approach to take and aligns with the desired formatting described in #4053.
Commit history isn't clean, let me know if I should squash this before it can be merged.
LLM Usage Disclosure
I used an LLM to assist me in exploring the codebase and to write parts of the PR. LLM-written code was then reviewed and edited by me. Unfortunately I don't remember specific details about what exactly was LLM-written vs manually-written, since I initially put this PR up several months ago.