Single-line `where` clauses may be 1 character too long
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
With default settings, rustfmt thinks the following code is formatted:
//-------1---------2---------3---------4---------5---------6---------7---------8---------9---------!
//34567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
impl<E> Tt for Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa where E: Tttttttttttttttttttttttttttttttttt1
{}
But the impl header is 101 characters long. If it is made any longer, rustfmt will correctly wrap it to the next line, but at this exact length, rustfmt uses single-line formatting when it shouldn't.
This may be related to #5321, which involves trait bounds but not where.
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
Reproduce the issue using the Rust code example and rustfmt's default settings, then trace the formatter logic for single-line impl headers with where clauses. Confirm the fix by checking that the 101-character header wraps while shorter equivalent headers retain single-line formatting.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100