wrap else to next line if let-else pattern is multi-lined

This rule wasn't explicity stated in the style guide so it was missed,
but luckily we caught it during testing.
This commit is contained in:
Yacin Tmimi 2023-06-27 12:30:27 -04:00 committed by Caleb Cartwright
parent 7b4e8a6d31
commit 1de65a2711
4 changed files with 8 additions and 5 deletions

View File

@ -127,8 +127,8 @@ fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String>
if let Some(block) = else_block {
let else_kw_span = init.span.between(block.span);
let force_newline_else =
!same_line_else_kw_and_brace(&result, context, else_kw_span, nested_shape);
let force_newline_else = pat_str.contains('\n')
|| !same_line_else_kw_and_brace(&result, context, else_kw_span, nested_shape);
let else_kw = rewrite_else_kw_with_comments(
force_newline_else,
true,

View File

@ -24,7 +24,8 @@ fn main() {
upper,
step,
range: _,
}) = slice.as_ref() else {
}) = slice.as_ref()
else {
return;
};

View File

@ -26,7 +26,8 @@ fn main() {
upper,
step,
range: _,
}) = slice.as_ref() else {
}) = slice.as_ref()
else {
return;
};

View File

@ -30,7 +30,8 @@ fn main() {
upper,
step,
range: _,
}) = slice.as_ref() else {
}) = slice.as_ref()
else {
return;
};