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');
} 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(", ");
--- /dev/null
+// 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;
+}
--- /dev/null
+// 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;
+}