]> git.lizzy.rs Git - rust.git/commitdiff
Preserve trailing comma on macro call when using mixed layout
authorSeiichi Uchida <seiichi.uchida@dena.com>
Thu, 12 Apr 2018 00:54:00 +0000 (09:54 +0900)
committerSeiichi Uchida <seiichi.uchida@dena.com>
Thu, 12 Apr 2018 00:54:00 +0000 (09:54 +0900)
src/lists.rs
tests/source/macros.rs
tests/target/macros.rs

index c4bd21869fb37a9a50f0574ddc4c42187b0184b1..a14d1907a8c169ecb912b05a660be47ff45af72f 100644 (file)
@@ -279,10 +279,7 @@ pub fn write_list<I, T>(items: I, formatting: &ListFormatting) -> Option<String>
                 }
 
                 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 {
index 6e730fffbf6136a18fbee536e2018012e331a4d9..cd45b7a5d3f4262b0f154e63789a2c2347f4ccf6 100644 (file)
@@ -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,);
+}
index d430f5711dd8e7d034cfc9aa68b5c380d1250caf..76e538bb85d49fe6a0a0426778153b73a6d87831 100644 (file)
@@ -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,
+    );
+}