diff --git a/src/lists.rs b/src/lists.rs index c4bd21869fb..a14d1907a8c 100644 --- a/src/lists.rs +++ b/src/lists.rs @@ -279,10 +279,7 @@ where } if last && formatting.ends_with_newline { - match formatting.trailing_separator { - SeparatorTactic::Always | SeparatorTactic::Vertical => separate = true, - _ => (), - } + separate = formatting.trailing_separator != SeparatorTactic::Never; } if line_len > 0 { diff --git a/tests/source/macros.rs b/tests/source/macros.rs index 6e730fffbf6..cd45b7a5d3f 100644 --- a/tests/source/macros.rs +++ b/tests/source/macros.rs @@ -373,3 +373,10 @@ fn foo() { fn foo() { let _ = column!(/* here */); } + +// #2616 +// Preserve trailing comma when using mixed layout for macro call. +fn foo() { + foo!(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); + foo!(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,); +} diff --git a/tests/target/macros.rs b/tests/target/macros.rs index d430f5711dd..76e538bb85d 100644 --- a/tests/target/macros.rs +++ b/tests/target/macros.rs @@ -948,3 +948,16 @@ fn foo() { fn foo() { let _ = column!(/* here */); } + +// #2616 +// Preserve trailing comma when using mixed layout for macro call. +fn foo() { + foo!( + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 + ); + foo!( + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + ); +}