diff --git a/src/formatting/expr.rs b/src/formatting/expr.rs index 80c241a5ac6..421f7ab6655 100644 --- a/src/formatting/expr.rs +++ b/src/formatting/expr.rs @@ -1654,7 +1654,10 @@ fn rewrite_struct_lit<'a>( nested_shape, tactic, context, - force_no_trailing_comma || has_base || !context.use_block_indent(), + force_no_trailing_comma + || has_base + || !context.use_block_indent() + || matches!(struct_rest, ast::StructRest::Rest(_)), ); write_list(&item_vec, &fmt)? diff --git a/tests/source/issue_4675.rs b/tests/source/issue_4675.rs new file mode 100644 index 00000000000..66613eed000 --- /dev/null +++ b/tests/source/issue_4675.rs @@ -0,0 +1,8 @@ +macro_rules! foo { + ($s:ident ( $p:pat )) => { + Foo { + name: Name::$s($p), + .. + } + }; +} \ No newline at end of file diff --git a/tests/target/issue_4675.rs b/tests/target/issue_4675.rs new file mode 100644 index 00000000000..a65f86832ee --- /dev/null +++ b/tests/target/issue_4675.rs @@ -0,0 +1,8 @@ +macro_rules! foo { + ($s:ident ( $p:pat )) => { + Foo { + name: Name::$s($p), + .. + } + }; +}