rustfmt puts `where` on same line as `impl` for empty `impl` even if long
Open
Nobody has claimed this yet.
I-poor-formatting
S-blocked
X-requires-next-style-edition
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
Given the following code:
impl<T: ?Sized, Idx> IndexRanges<Idx> for T
where
T: Index<Range<Idx>, Output = Self::Output>
+ Index<RangeTo<Idx>, Output = Self::Output>
+ Index<RangeFrom<Idx>, Output = Self::Output>
+ Index<RangeInclusive<Idx>, Output = Self::Output>
+ Index<RangeToInclusive<Idx>, Output = Self::Output>
+ Index<RangeFull>,
{
}
rustfmt moves the where onto the same line as the impl. However, if you put a fn func() {} inside, it won't.
This may need to wait for a style edition to fix.
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 reproducing the issue with the empty and non-empty impl examples in the report, then trace rustfmt's handling of impl blocks and where clauses. Done means the empty impl follows the intended line-breaking behavior without changing the non-empty case, with coverage for the reported example.
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