forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent duplicate comma when formatting struct pattern with ".."
Fixes 5066 When a struct pattern that contained a ".." was formatted, it was assumed that a trailing comma should always be added if the struct fields weren't formatted vertically. Now, a trailing comma is only added if not already included in the reformatted struct fields.
- Loading branch information
1 parent
740fb57
commit 57ac92b
Showing
7 changed files
with
54 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
tests/target/issue-5066/multi_line_struct_trailing_comma_always_struct_lit_width_0.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// rustfmt-trailing_comma: Always | ||
// rustfmt-struct_lit_single_line: false | ||
// rustfmt-struct_lit_width: 0 | ||
|
||
fn main() { | ||
let Foo { | ||
a, | ||
.. | ||
} = b; | ||
} |
10 changes: 10 additions & 0 deletions
10
tests/target/issue-5066/multi_line_struct_trailing_comma_never_struct_lit_width_0.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// rustfmt-trailing_comma: Never | ||
// rustfmt-struct_lit_single_line: false | ||
// rustfmt-struct_lit_width: 0 | ||
|
||
fn main() { | ||
let Foo { | ||
a, | ||
.. | ||
} = b; | ||
} |
10 changes: 10 additions & 0 deletions
10
tests/target/issue-5066/multi_line_struct_with_trailing_comma_always.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// rustfmt-trailing_comma: Always | ||
// rustfmt-struct_lit_single_line: false | ||
|
||
// There is an issue with how this is formatted. | ||
// formatting should look like ./multi_line_struct_trailing_comma_always_struct_lit_width_0.rs | ||
fn main() { | ||
let Foo { | ||
a, .. | ||
} = b; | ||
} |
10 changes: 10 additions & 0 deletions
10
tests/target/issue-5066/multi_line_struct_with_trailing_comma_never.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// rustfmt-trailing_comma: Never | ||
// rustfmt-struct_lit_single_line: false | ||
|
||
// There is an issue with how this is formatted. | ||
// formatting should look like ./multi_line_struct_trailing_comma_never_struct_lit_width_0.rs | ||
fn main() { | ||
let Foo { | ||
a, .. | ||
} = b; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// rustfmt-trailing_comma: Always | ||
|
||
fn main() { | ||
let Foo { a, .. } = b; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// rustfmt-trailing_comma: Never | ||
|
||
fn main() { | ||
let Foo { a, .. } = b; | ||
} |