Skip to content

Commit ba5b4fa

Browse files
authored
Merge pull request #2617 from topecongiro/issue-2616
Preserve trailing comma on macro call when using mixed layout
2 parents 1cab171 + e58e977 commit ba5b4fa

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

src/lists.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,10 +279,7 @@ where
279279
}
280280

281281
if last && formatting.ends_with_newline {
282-
match formatting.trailing_separator {
283-
SeparatorTactic::Always | SeparatorTactic::Vertical => separate = true,
284-
_ => (),
285-
}
282+
separate = formatting.trailing_separator != SeparatorTactic::Never;
286283
}
287284

288285
if line_len > 0 {

tests/source/macros.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,3 +373,10 @@ fn foo() {
373373
fn foo() {
374374
let _ = column!(/* here */);
375375
}
376+
377+
// #2616
378+
// Preserve trailing comma when using mixed layout for macro call.
379+
fn foo() {
380+
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);
381+
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,);
382+
}

tests/target/macros.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -948,3 +948,16 @@ fn foo() {
948948
fn foo() {
949949
let _ = column!(/* here */);
950950
}
951+
952+
// #2616
953+
// Preserve trailing comma when using mixed layout for macro call.
954+
fn foo() {
955+
foo!(
956+
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
957+
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
958+
);
959+
foo!(
960+
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
961+
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
962+
);
963+
}

0 commit comments

Comments
 (0)