diff --git a/src/expr.rs b/src/expr.rs index c4b01e38b42..5a281f2df83 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -1335,7 +1335,10 @@ fn rewrite_struct_lit<'a>(context: &RewriteContext, }, indent: indent, width: budget, - ends_with_newline: false, + ends_with_newline: match context.config.struct_lit_style { + StructLitStyle::Block => true, + StructLitStyle::Visual => false, + }, config: context.config, }; let fields_str = try_opt!(write_list(&item_vec, &fmt)); diff --git a/tests/source/struct_lits_multiline.rs b/tests/source/struct_lits_multiline.rs index b6395884713..dc0470b1447 100644 --- a/tests/source/struct_lits_multiline.rs +++ b/tests/source/struct_lits_multiline.rs @@ -71,3 +71,10 @@ fn issue201() { fn issue201_2() { let s = S{a: S2{ .. c}, .. b}; } + +fn issue491() { + Foo { + guard: None, + arm: 0, // Comment + }; +} diff --git a/tests/target/struct_lits.rs b/tests/target/struct_lits.rs index e0b29184162..445b8028340 100644 --- a/tests/target/struct_lits.rs +++ b/tests/target/struct_lits.rs @@ -25,7 +25,7 @@ fn main() { // Comment a: foo(), // Comment // Comment - b: bar(), /* Comment */ + b: bar(), // Comment }; Foo { a: Bar, b: f() }; diff --git a/tests/target/struct_lits_multiline.rs b/tests/target/struct_lits_multiline.rs index 893c9dba888..91ead9e764a 100644 --- a/tests/target/struct_lits_multiline.rs +++ b/tests/target/struct_lits_multiline.rs @@ -32,7 +32,7 @@ fn main() { // Comment a: foo(), // Comment // Comment - b: bar(), /* Comment */ + b: bar(), // Comment }; Foo { @@ -107,3 +107,10 @@ fn issue201_2() { ..b }; } + +fn issue491() { + Foo { + guard: None, + arm: 0, // Comment + }; +}