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

Commit 7b99654

Browse files
committed
change new line point in the case of no args
1 parent d2e91b5 commit 7b99654

File tree

4 files changed

+21
-6
lines changed

4 files changed

+21
-6
lines changed

src/items.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2064,6 +2064,8 @@ fn rewrite_fn_base(
20642064
} && !fd.inputs.is_empty();
20652065

20662066
let mut args_last_line_contains_comment = false;
2067+
let mut no_args_and_over_max_width = false;
2068+
20672069
if put_args_in_block {
20682070
arg_indent = indent.block_indent(context.config);
20692071
result.push_str(&arg_indent.to_string_with_newline(context.config));
@@ -2083,10 +2085,12 @@ fn rewrite_fn_base(
20832085
.lines()
20842086
.last()
20852087
.map_or(false, |last_line| last_line.contains("//"));
2088+
result.push(')');
2089+
20862090
if closing_paren_overflow_max_width || args_last_line_contains_comment {
20872091
result.push_str(&indent.to_string_with_newline(context.config));
2092+
no_args_and_over_max_width = true;
20882093
}
2089-
result.push(')');
20902094
}
20912095

20922096
// Return type.
@@ -2126,7 +2130,9 @@ fn rewrite_fn_base(
21262130
result.push_str(&indent.to_string_with_newline(context.config));
21272131
indent
21282132
} else {
2129-
result.push(' ');
2133+
if arg_str.len() != 0 || !no_args_and_over_max_width {
2134+
result.push(' ');
2135+
}
21302136
Indent::new(indent.block_indent, last_line_width(&result))
21312137
};
21322138

tests/source/issue-3278.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pub fn parse_conditional<'a, I: 'a>() -> impl Parser<Input = I, Output = Expr, PartialState = ()> + 'a
2+
where I: Stream<Item = char>
3+
{}

tests/target/issue-3278.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pub fn parse_conditional<'a, I: 'a>()
2+
-> impl Parser<Input = I, Output = Expr, PartialState = ()> + 'a
3+
where
4+
I: Stream<Item = char>,
5+
{
6+
}

tests/target/long-fn-1.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ impl Foo {
1515

1616
// #1843
1717
#[allow(non_snake_case)]
18-
pub extern "C" fn Java_com_exonum_binding_storage_indices_ValueSetIndexProxy_nativeContainsByHash(
19-
) -> bool {
18+
pub extern "C" fn Java_com_exonum_binding_storage_indices_ValueSetIndexProxy_nativeContainsByHash()
19+
-> bool {
2020
false
2121
}
2222

2323
// #3009
2424
impl Something {
25-
fn my_function_name_is_way_to_long_but_used_as_a_case_study_or_an_example_its_fine(
26-
) -> Result<(), String> {
25+
fn my_function_name_is_way_to_long_but_used_as_a_case_study_or_an_example_its_fine()
26+
-> Result<(), String> {
2727
}
2828
}

0 commit comments

Comments
 (0)