Supertraits are wrapped at less than `max_width` (sometimes 20+ chars less)
Open
Nobody has claimed this yet.
C-bug
S-has-mcve
SO-max_width
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
If I format this code with max_width = 50:
// line below is 30 chars
pub(super) unsafe trait A: B {
fn foo();
}
// line below is 36 chars
pub unsafe trait Trait2: A + B + C {
fn foo();
}
// line below is 43 chars
pub trait TraitThree: Super1 + Super2 + X {
fn foo();
}
// line below is 47 chars
trait TraitNumberFour: Super1 + Super2 + Abcd {
fn foo();
}
// line below is correctly not wrapped
pub const THIS_LINE_IS_50_CHARS: usize = 12345678;
I get this:
// line below is 30 chars
pub(super) unsafe trait A:
B
{
fn foo();
}
// line below is 36 chars
pub unsafe trait Trait2:
A + B + C
{
fn foo();
}
// line below is 43 chars
pub trait TraitThree:
Super1 + Super2 + X
{
fn foo();
}
// line below is 47 chars
trait TraitNumberFour:
Super1 + Super2 + Abcd
{
fn foo();
}
// line below is correctly not wrapped
pub const THIS_LINE_IS_50_CHARS: usize = 12345678;
All of the supertraits were moved to a separate line even though none of the original lines exceeded the max width.
The same thing happens with other values of max_width, including the default of 100.
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
No source file or test is named. Reproduce the examples with max_width values of 50 and 100, then trace the formatter's supertrait wrapping behavior. Done means lines that already fit within max_width remain unwrapped, with regression coverage for the shown trait declarations.
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
- Clearly specified
- Newbie friendliness
- 45/100