diff options
| author | Caleb Cartwright <caleb.cartwright@outlook.com> | 2021-12-29 20:49:39 -0600 |
|---|---|---|
| committer | Caleb Cartwright <caleb.cartwright@outlook.com> | 2021-12-29 20:49:39 -0600 |
| commit | 6db6bafc61b6f4f782c5f10e8dbe3f006c41fc5d (patch) | |
| tree | 590f289ac45203fc8330dfb513aa0d148aeada9f /src/patterns.rs | |
| parent | 122e1c3802afcaa803287b06127c499df63e2dab (diff) | |
Merge commit '4a053f206fd6799a25823c307f7d7f9d897be118' into sync-rustfmt-subtree
Diffstat (limited to 'src/patterns.rs')
| -rw-r--r-- | src/patterns.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/patterns.rs b/src/patterns.rs index a80d63201f9..9b74b35f314 100644 --- a/src/patterns.rs +++ b/src/patterns.rs @@ -318,10 +318,12 @@ fn rewrite_struct_pat( let mut fields_str = write_list(&item_vec, &fmt)?; let one_line_width = h_shape.map_or(0, |shape| shape.width); + let has_trailing_comma = fmt.needs_trailing_separator(); + if ellipsis { if fields_str.contains('\n') || fields_str.len() > one_line_width { // Add a missing trailing comma. - if context.config.trailing_comma() == SeparatorTactic::Never { + if !has_trailing_comma { fields_str.push(','); } fields_str.push('\n'); @@ -329,8 +331,7 @@ fn rewrite_struct_pat( } else { if !fields_str.is_empty() { // there are preceding struct fields being matched on - if tactic == DefinitiveListTactic::Vertical { - // if the tactic is Vertical, write_list already added a trailing , + if has_trailing_comma { fields_str.push(' '); } else { fields_str.push_str(", "); |
