mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-24 12:54:00 +00:00
Merge pull request #1442 from topecongiro/poor-formatting/trailing-comma
Remove comma from function definition with a single argument
This commit is contained in:
commit
459b4449a6
@ -1750,7 +1750,8 @@ fn rewrite_call_inner<R>(context: &RewriteContext,
|
||||
tactic: tactic,
|
||||
separator: ",",
|
||||
trailing_separator: if force_no_trailing_comma ||
|
||||
context.config.fn_call_style == IndentStyle::Visual {
|
||||
context.config.fn_call_style == IndentStyle::Visual ||
|
||||
args.len() <= 1 {
|
||||
SeparatorTactic::Never
|
||||
} else {
|
||||
context.config.trailing_comma
|
||||
|
@ -1619,7 +1619,8 @@ fn rewrite_fn_base(context: &RewriteContext,
|
||||
indent,
|
||||
arg_indent,
|
||||
args_span,
|
||||
fd.variadic));
|
||||
fd.variadic,
|
||||
generics_str.contains('\n')));
|
||||
|
||||
let multi_line_arg_str = arg_str.contains('\n');
|
||||
|
||||
@ -1773,7 +1774,8 @@ fn rewrite_args(context: &RewriteContext,
|
||||
indent: Indent,
|
||||
arg_indent: Indent,
|
||||
span: Span,
|
||||
variadic: bool)
|
||||
variadic: bool,
|
||||
generics_str_contains_newline: bool)
|
||||
-> Option<String> {
|
||||
let mut arg_item_strs =
|
||||
try_opt!(args.iter()
|
||||
@ -1858,6 +1860,9 @@ fn rewrite_args(context: &RewriteContext,
|
||||
}
|
||||
|
||||
let (indent, trailing_comma, end_with_newline) = match context.config.fn_args_layout {
|
||||
IndentStyle::Block if !generics_str_contains_newline && arg_items.len() <= 1 => {
|
||||
(indent.block_indent(context.config), SeparatorTactic::Never, true)
|
||||
}
|
||||
IndentStyle::Block => {
|
||||
(indent.block_indent(context.config), SeparatorTactic::Vertical, true)
|
||||
}
|
||||
|
@ -3,4 +3,6 @@
|
||||
|
||||
fn main() {
|
||||
lorem("lorem", "ipsum", "dolor", "sit", "amet", "consectetur", "adipiscing", "elit");
|
||||
// #1501
|
||||
let hyper = Arc::new(Client::with_connector(HttpsConnector::new(TlsClient::new())));
|
||||
}
|
||||
|
@ -12,4 +12,6 @@ fn main() {
|
||||
"adipiscing",
|
||||
"elit",
|
||||
);
|
||||
// #1501
|
||||
let hyper = Arc::new(Client::with_connector(HttpsConnector::new(TlsClient::new())));
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ fn arrays() {
|
||||
Weighted { weight: 1, item: 1 },
|
||||
Weighted { weight: x, item: 2 },
|
||||
Weighted { weight: 1, item: 3 },
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
let z = [
|
||||
|
@ -4,7 +4,7 @@
|
||||
// rustfmt-fn_brace_style: AlwaysNextLine
|
||||
|
||||
// Case with only one variable.
|
||||
fn foo(a: u8,) -> u8
|
||||
fn foo(a: u8) -> u8
|
||||
{
|
||||
bar()
|
||||
}
|
||||
@ -30,11 +30,11 @@ fn foo(
|
||||
}
|
||||
|
||||
trait Test {
|
||||
fn foo(a: u8,)
|
||||
fn foo(a: u8)
|
||||
{
|
||||
}
|
||||
|
||||
fn bar(a: u8,) -> String
|
||||
fn bar(a: u8) -> String
|
||||
{
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user