Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit d835748

Browse files
committed
Refactor the corner case of handling long function
1 parent 9674e12 commit d835748

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/items.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2040,18 +2040,16 @@ fn rewrite_fn_base(
20402040
let used_width = last_line_used_width(&result, indent.width()) + first_line_width(&ret_str);
20412041
// Put the closing brace on the next line if it overflows the max width.
20422042
// 1 = `)`
2043-
if fd.inputs.is_empty() && used_width + 1 > context.config.max_width() {
2044-
result.push('\n');
2045-
}
2043+
let closing_paren_overflow_max_width =
2044+
fd.inputs.is_empty() && used_width + 1 > context.config.max_width();
20462045
// If the last line of args contains comment, we cannot put the closing paren
20472046
// on the same line.
2048-
if arg_str
2047+
args_last_line_contains_comment = arg_str
20492048
.lines()
20502049
.last()
2051-
.map_or(false, |last_line| last_line.contains("//"))
2052-
{
2053-
args_last_line_contains_comment = true;
2054-
result.push_str(&arg_indent.to_string_with_newline(context.config));
2050+
.map_or(false, |last_line| last_line.contains("//"));
2051+
if closing_paren_overflow_max_width || args_last_line_contains_comment {
2052+
result.push_str(&indent.to_string_with_newline(context.config));
20552053
}
20562054
result.push(')');
20572055
}

0 commit comments

Comments
 (0)