diff --git a/src/expr.rs b/src/expr.rs index 5a281f2df83..7e0407465b9 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -1335,9 +1335,10 @@ fn rewrite_struct_lit<'a>(context: &RewriteContext, }, indent: indent, width: budget, - ends_with_newline: match context.config.struct_lit_style { - StructLitStyle::Block => true, - StructLitStyle::Visual => false, + ends_with_newline: match tactic { + DefinitiveListTactic::Horizontal => false, + DefinitiveListTactic::Vertical => true, + DefinitiveListTactic::Mixed => unreachable!(), }, config: context.config, }; diff --git a/tests/source/struct_lits.rs b/tests/source/struct_lits.rs index 98ac6fab799..0c30d721c4d 100644 --- a/tests/source/struct_lits.rs +++ b/tests/source/struct_lits.rs @@ -110,4 +110,7 @@ fn issue491() { Foo { arm: 0, // Comment }; + + Foo { a: aaaaaaaaaa, b: bbbbbbbb, c: cccccccccc, d: dddddddddd, /* a comment */ + e: eeeeeeeee }; } diff --git a/tests/target/struct_lits.rs b/tests/target/struct_lits.rs index 3ece0cb23a3..a08222f8f13 100644 --- a/tests/target/struct_lits.rs +++ b/tests/target/struct_lits.rs @@ -140,4 +140,12 @@ fn issue491() { }; Foo { arm: 0 /* Comment */ }; + + Foo { + a: aaaaaaaaaa, + b: bbbbbbbb, + c: cccccccccc, + d: dddddddddd, // a comment + e: eeeeeeeee, + }; }