Merge pull request #1529 from topecongiro/issue-1528

Use newline only when fn_call_style is Block
This commit is contained in:
Nick Cameron 2017-05-12 15:04:01 +12:00 committed by GitHub
commit 88250c4af2
5 changed files with 34 additions and 1 deletions

View file

@ -1779,7 +1779,12 @@ fn rewrite_call_args(context: &RewriteContext,
};
match write_list(&item_vec, &fmt) {
Some(ref s) if !s.contains('\n') && s.len() > one_line_width => {
// If arguments do not fit in a single line and do not contain newline,
// try to put it on the next line. Try this only when we are in block mode
// 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) => {
fmt.trailing_separator = SeparatorTactic::Vertical;
write_list(&item_vec, &fmt)
}

View file

@ -0,0 +1,7 @@
// rustfmt-error_on_line_overflow: false
// rustfmt-fn_call_style: Block
// rustfmt should not add trailing comma when rewriting macro. See #1528.
fn a() {
panic!("this is a long string that goes past the maximum line length causing rustfmt to insert a comma here:");
}

View file

@ -0,0 +1,7 @@
// rustfmt-error_on_line_overflow: false
// rustfmt-fn_call_style: Visual
// rustfmt should not add trailing comma when rewriting macro. See #1528.
fn a() {
panic!("this is a long string that goes past the maximum line length causing rustfmt to insert a comma here:");
}

View file

@ -0,0 +1,7 @@
// rustfmt-error_on_line_overflow: false
// rustfmt-fn_call_style: Block
// rustfmt should not add trailing comma when rewriting macro. See #1528.
fn a() {
panic!("this is a long string that goes past the maximum line length causing rustfmt to insert a comma here:");
}

View file

@ -0,0 +1,7 @@
// rustfmt-error_on_line_overflow: false
// rustfmt-fn_call_style: Visual
// rustfmt should not add trailing comma when rewriting macro. See #1528.
fn a() {
panic!("this is a long string that goes past the maximum line length causing rustfmt to insert a comma here:");
}