From: Seiichi Uchida Date: Thu, 12 Apr 2018 00:54:00 +0000 (+0900) Subject: Preserve trailing comma on macro call when using mixed layout X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=e58e97783ee865a0603e5be59e7116cc19f5ae2b;p=rust.git Preserve trailing comma on macro call when using mixed layout --- 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 @@ pub fn write_list(items: I, formatting: &ListFormatting) -> Option } 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, + ); +}