fix: don't force a newline after an empty where clause

Fixes #4547.
This commit is contained in:
meiomorphism 2020-11-25 04:31:10 -08:00 committed by Caleb Cartwright
parent 073cc3891f
commit 003786228d
2 changed files with 24 additions and 1 deletions

View File

@ -2418,7 +2418,8 @@ fn rewrite_fn_base(
result.push_str(&where_clause_str);
force_new_line_for_brace |= last_line_contains_single_line_comment(&result);
force_new_line_for_brace |= is_params_multi_lined && context.config.where_single_line();
force_new_line_for_brace |=
is_params_multi_lined && context.config.where_single_line() && !where_clause_str.is_empty();
Some((result, force_new_line_for_brace))
}

View File

@ -0,0 +1,22 @@
// rustfmt-brace_style: SameLineWhere
// rustfmt-where_single_line: true
fn lorem_multi_line_clauseless<Ipsum, Dolor, Sit, Amet>(
a: Aaaaaaaaaaaaaaa,
b: Bbbbbbbbbbbbbbbb,
c: Ccccccccccccccccc,
d: Ddddddddddddddddddddddddd,
e: Eeeeeeeeeeeeeeeeeee,
) -> T {
// body
}
fn lorem_multi_line_clauseless<Ipsum, Dolor, Sit, Amet>(
a: Aaaaaaaaaaaaaaa,
b: Bbbbbbbbbbbbbbbb,
c: Ccccccccccccccccc,
d: Ddddddddddddddddddddddddd,
e: Eeeeeeeeeeeeeeeeeee,
) {
// body
}