Skip to content

Commit

Permalink
Forbid trailing comma at the end of args of variadic functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Seiichi Uchida committed Jun 3, 2017
1 parent 5650411 commit 08b5375
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/items.rs
Expand Up @@ -1944,7 +1944,11 @@ fn rewrite_args(context: &RewriteContext,
let fmt = ListFormatting {
tactic: tactic,
separator: ",",
trailing_separator: trailing_comma,
trailing_separator: if variadic {
SeparatorTactic::Never
} else {
trailing_comma
},
shape: Shape::legacy(budget, indent),
ends_with_newline: end_with_newline,
config: context.config,
Expand Down
6 changes: 6 additions & 0 deletions tests/source/configs-fn_args_layout-block.rs
Expand Up @@ -14,3 +14,9 @@ extern "system" {
pub fn GetConsoleHistoryInfo(console_history_info: *mut ConsoleHistoryInfo) -> Boooooooooooooool;
}

// rustfmt should not add trailing comma for variadic function. See #1623.
extern "C" {
pub fn variadic_fn(first_parameter: FirstParameterType,
second_parameter: SecondParameterType,
...);
}
9 changes: 9 additions & 0 deletions tests/target/configs-fn_args_layout-block.rs
Expand Up @@ -23,3 +23,12 @@ extern "system" {
console_history_info: *mut ConsoleHistoryInfo,
) -> Boooooooooooooool;
}

// rustfmt should not add trailing comma for variadic function. See #1623.
extern "C" {
pub fn variadic_fn(
first_parameter: FirstParameterType,
second_parameter: SecondParameterType,
...
);
}

0 comments on commit 08b5375

Please sign in to comment.