Skip to content

Commit 233497a

Browse files
rchaser53topecongiro
authored andcommitted
fix Unparsable code when formmating (rust-lang#3883)
1 parent 69c7dbc commit 233497a

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/items.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -2218,10 +2218,16 @@ fn rewrite_fn_base(
22182218
.map_or(false, |last_line| last_line.contains("//"));
22192219

22202220
if context.config.version() == Version::Two {
2221-
result.push(')');
2222-
if closing_paren_overflow_max_width || params_last_line_contains_comment {
2221+
if closing_paren_overflow_max_width {
2222+
result.push(')');
22232223
result.push_str(&indent.to_string_with_newline(context.config));
22242224
no_params_and_over_max_width = true;
2225+
} else if params_last_line_contains_comment {
2226+
result.push_str(&indent.to_string_with_newline(context.config));
2227+
result.push(')');
2228+
no_params_and_over_max_width = true;
2229+
} else {
2230+
result.push(')');
22252231
}
22262232
} else {
22272233
if closing_paren_overflow_max_width || params_last_line_contains_comment {

tests/target/issue-3882.rs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// rustfmt-version: Two
2+
fn bar(_t: T, // bar
3+
) {
4+
}

0 commit comments

Comments
 (0)