improve formatting of boolean expression with groups
Open
Nobody has claimed this yet.
A-binary-ops
C-feature-request
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
I think the formatting of the following boolean expression could be improved so that it is clear that:
- the first two operands are OR'ed
- and its result is AND'ed with the third operand.
A possible formatting would be:
let force_newline_brace =
(pat_expr_string.contains('\n') || pat_expr_string.len() > one_line_budget)
&& !last_line_extendable(&pat_expr_string);
If there is not enough space, we could have something like:
let force_newline_brace =
(pat_expr_string12345678.contains('\n')
|| pat_expr_string123456789.len() > one_line_budget)
&& !last_line_extendable(&pat_expr_string);
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 with src/expr.rs around lines 886-888, where the boolean expression is formatted. Compare the current output with the grouped examples in the issue and trace the surrounding formatting logic. Done means rustfmt produces grouping that makes the OR operands and their AND relationship clear, including when the expression wraps.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 58/100