-
Notifications
You must be signed in to change notification settings - Fork 996
Fix supertrait wrapping when within max_width #6814
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| // rustfmt-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; | ||
|
Comment on lines
+23
to
+24
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similarly, I'm not sure why we have an example with |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| // rustfmt-style_edition: 2027 | ||
| // rustfmt-max_width: 100 | ||
|
|
||
| // line below is 80 chars | ||
| pub(super) unsafe trait ALetsMakeThisLineLongerByExactlyFiftyCharacters1234: B { | ||
| fn foo(); | ||
| } | ||
|
|
||
| // line below is 86 chars | ||
| pub unsafe trait Trait2LetsMakeThisLineLongerByExactlyFiftyCharacters1234: A + B + C { | ||
| fn foo(); | ||
| } | ||
|
|
||
| // line below is 93 chars | ||
| pub trait TraitThreeLetsMakeThisLineLongerByExactlyFiftyCharacters1234: Super1 + Super2 + X { | ||
| fn foo(); | ||
| } | ||
|
|
||
| // line below is 97 chars | ||
| trait TraitNumberFourLetsMakeThisLineLongerByExactlyFiftyCharacters1234: Super1 + Super2 + Abcd { | ||
| fn foo(); | ||
| } | ||
|
Comment on lines
+19
to
+22
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a test case where the trait definition with super traits is exactly |
||
|
|
||
| // line below is correctly not wrapped | ||
| pub const THIS_LINE_IS_100_CHARS: &str = "12345678901234567890123456789012345678901234567890123456"; | ||
|
Comment on lines
+24
to
+25
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure why this is here. This PR is focusing on traits, not const items. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| // rustfmt-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; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| // rustfmt-style_edition: 2027 | ||
| // rustfmt-max_width: 100 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Question (for other rustfmt maintainers): I believe
I believe this fix needs to be gated behind a style-edition.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are right . I think gating this behind
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you will need to gate it behind
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Gated it behind StyleEdition::2027. Thanks! |
||
|
|
||
| // line below is 80 chars | ||
| pub(super) unsafe trait ALetsMakeThisLineLongerByExactlyFiftyCharacters1234: B { | ||
| fn foo(); | ||
| } | ||
|
|
||
| // line below is 86 chars | ||
| pub unsafe trait Trait2LetsMakeThisLineLongerByExactlyFiftyCharacters1234: A + B + C { | ||
| fn foo(); | ||
| } | ||
|
|
||
| // line below is 93 chars | ||
| pub trait TraitThreeLetsMakeThisLineLongerByExactlyFiftyCharacters1234: Super1 + Super2 + X { | ||
| fn foo(); | ||
| } | ||
|
|
||
| // line below is 97 chars | ||
| trait TraitNumberFourLetsMakeThisLineLongerByExactlyFiftyCharacters1234: Super1 + Super2 + Abcd { | ||
| fn foo(); | ||
| } | ||
|
|
||
| // line below is correctly not wrapped | ||
| pub const THIS_LINE_IS_100_CHARS: &str = "12345678901234567890123456789012345678901234567890123456"; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should consider naming this file
supertraits_max_width_50.rsfor consistency withsupertraits_max_width_100.rs