Feature request: Specify priority of small heuristics / line-breaking rules
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
I have noticed that rustfmt seems to prioritize breaking chains before it'll break on function arguments.
For example:
let value =
obj.func(&long_struct.arg1, long_struct.arg2, long_struct.arg3, true);
is preferred instead of:
let value = obj.func(
&long_struct.arg1,
long_struct.arg2,
long_struct.arg3,
true,
);
I have tried so hard to find configuration settings that will prefer the second style when a line is too long (according to max_width, chain_width, or fn_call_width). A quick way to see this behavior is to set all 3 of these config values to the same number (80).
Could a new config option be introduced (perhaps called small_heuristics_priority) that takes an array of the names of the other options in the order that they should be applied to fix the line?
small_heuristics_priority = [ "fn_call_width", "chain_width" ]
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 tracing how rustfmt applies max_width, chain_width, and fn_call_width when formatting the examples. Review the existing TOML configuration handling and related formatting tests, if present. Done means a documented priority setting can select the requested function-argument-first behavior and the examples format accordingly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100