Skip to content

Commit 01f2ec7

Browse files
authored
fixed formatting of commented single param in style_edition=2024 (#6840)
* fixed formatting of commented single param in style_edition=2024
1 parent bdab101 commit 01f2ec7

3 files changed

Lines changed: 17 additions & 4 deletions

File tree

src/items.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2586,13 +2586,13 @@ fn rewrite_fn_base(
25862586
.map_or(false, |last_line| last_line.contains("//"));
25872587

25882588
if context.config.style_edition() >= StyleEdition::Edition2024 {
2589-
if closing_paren_overflow_max_width {
2590-
result.push(')');
2589+
if params_last_line_contains_comment {
25912590
result.push_str(&indent.to_string_with_newline(context.config));
2591+
result.push(')');
25922592
no_params_and_over_max_width = true;
2593-
} else if params_last_line_contains_comment {
2594-
result.push_str(&indent.to_string_with_newline(context.config));
2593+
} else if closing_paren_overflow_max_width {
25952594
result.push(')');
2595+
result.push_str(&indent.to_string_with_newline(context.config));
25962596
no_params_and_over_max_width = true;
25972597
} else {
25982598
result.push(')');

tests/source/issue-6825.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// rustfmt-edition: 2024
2+
// rustfmt-style_edition: 2024
3+
pub async fn foo(
4+
// OriginalUri(original_uri): OriginalUri,
5+
) -> Option<Option<Option<Option<String>>>> {
6+
None
7+
}

tests/target/issue-6825.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// rustfmt-edition: 2024
2+
// rustfmt-style_edition: 2024
3+
pub async fn foo(// OriginalUri(original_uri): OriginalUri,
4+
) -> Option<Option<Option<Option<String>>>> {
5+
None
6+
}

0 commit comments

Comments
 (0)