Skip to content

Commit

Permalink
fix: don't force a newline after an empty where clause
Browse files Browse the repository at this point in the history
Fixes #4547.
  • Loading branch information
meiomorphism authored and calebcartwright committed Dec 9, 2020
1 parent ace3c14 commit 28799b8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/formatting/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2613,7 +2613,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))
}

Expand Down
22 changes: 22 additions & 0 deletions tests/target/configs/where_single_line/true-with-brace-style.rs
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 28799b8

Please sign in to comment.