From 384ce46eef041fe03858428a0b21187717724773 Mon Sep 17 00:00:00 2001 From: topecongiro Date: Fri, 12 May 2017 16:30:26 +0900 Subject: [PATCH] Use vertical layout when args len is larger than fn_call_width --- src/expr.rs | 3 ++- tests/source/configs-fn_call_width-zero.rs | 7 +++++++ tests/target/configs-fn_call_style-block.rs | 4 +++- tests/target/configs-fn_call_width-zero.rs | 9 +++++++++ 4 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 tests/source/configs-fn_call_width-zero.rs create mode 100644 tests/target/configs-fn_call_width-zero.rs diff --git a/src/expr.rs b/src/expr.rs index da9a96bf19f..4b34fd8bf6d 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -1784,7 +1784,8 @@ fn rewrite_call_args(context: &RewriteContext, // and not rewriting macro. Some(ref s) if context.config.fn_call_style == IndentStyle::Block && !force_no_trailing_comma && - (!s.contains('\n') && s.len() > one_line_width) => { + (!s.contains('\n') && + (s.len() > one_line_width || s.len() > context.config.fn_call_width)) => { fmt.trailing_separator = SeparatorTactic::Vertical; write_list(&item_vec, &fmt) } diff --git a/tests/source/configs-fn_call_width-zero.rs b/tests/source/configs-fn_call_width-zero.rs new file mode 100644 index 00000000000..ee79c4ce805 --- /dev/null +++ b/tests/source/configs-fn_call_width-zero.rs @@ -0,0 +1,7 @@ +// rustfmt-fn_call_width: 0 +// rustfmt-fn_call_style: block + +// #1508 +fn a() { + let x = f(y); +} diff --git a/tests/target/configs-fn_call_style-block.rs b/tests/target/configs-fn_call_style-block.rs index d7cb12dd94c..c9a42cd4952 100644 --- a/tests/target/configs-fn_call_style-block.rs +++ b/tests/target/configs-fn_call_style-block.rs @@ -13,7 +13,9 @@ fn main() { "elit", ); // #1501 - let hyper = Arc::new(Client::with_connector(HttpsConnector::new(TlsClient::new()))); + let hyper = Arc::new( + Client::with_connector(HttpsConnector::new(TlsClient::new())), + ); } // #1521 diff --git a/tests/target/configs-fn_call_width-zero.rs b/tests/target/configs-fn_call_width-zero.rs new file mode 100644 index 00000000000..3193bc228f7 --- /dev/null +++ b/tests/target/configs-fn_call_width-zero.rs @@ -0,0 +1,9 @@ +// rustfmt-fn_call_width: 0 +// rustfmt-fn_call_style: block + +// #1508 +fn a() { + let x = f( + y, + ); +}