If-chain wrapping when `use_small_heuristics = "Max"`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
This is a follow up to https://github.com/rust-lang/style-team/issues/169#issuecomment-1723205191. Currently, rustfmt is formatting if-chains on nightly, but it uses a line-break-heavy style that is the current front-runner on https://github.com/rust-lang/style-team/issues/169 and other popular styles also exist. In particular, use_small_heuristics = "Max" is IMO a strong indication of intent from the author to not have spurious line breaks, and rustfmt should instead format let chains the same as regular binary operators, filling the line if space permits. (An option specific to if-chains is also reasonable, but use_small_heuristics = "Max" should imply it.)
before:
if let 1 = 1
&& true
{
}
after:
if let 1 = 1 && true {}
This relates to a discussion on Zulip.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating rustfmt's handling of let chains, if-chain wrapping, and use_small_heuristics; compare it with formatting for regular binary operators. Add coverage for the before and after examples, and consider the related style discussion when determining the expected output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100