diff --git a/src/formatting/items.rs b/src/formatting/items.rs index 2e703d127b3..2bf3138ae5a 100644 --- a/src/formatting/items.rs +++ b/src/formatting/items.rs @@ -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)) } diff --git a/tests/target/configs/where_single_line/true-with-brace-style.rs b/tests/target/configs/where_single_line/true-with-brace-style.rs new file mode 100644 index 00000000000..ec7f79b689c --- /dev/null +++ b/tests/target/configs/where_single_line/true-with-brace-style.rs @@ -0,0 +1,22 @@ +// rustfmt-brace_style: SameLineWhere +// rustfmt-where_single_line: true + +fn lorem_multi_line_clauseless( + a: Aaaaaaaaaaaaaaa, + b: Bbbbbbbbbbbbbbbb, + c: Ccccccccccccccccc, + d: Ddddddddddddddddddddddddd, + e: Eeeeeeeeeeeeeeeeeee, +) -> T { + // body +} + +fn lorem_multi_line_clauseless( + a: Aaaaaaaaaaaaaaa, + b: Bbbbbbbbbbbbbbbb, + c: Ccccccccccccccccc, + d: Ddddddddddddddddddddddddd, + e: Eeeeeeeeeeeeeeeeeee, +) { + // body +}