change new line point in the case of no args
This commit is contained in:
parent
d2e91b5b68
commit
7b996542cc
4 changed files with 21 additions and 6 deletions
10
src/items.rs
10
src/items.rs
|
@ -2064,6 +2064,8 @@ fn rewrite_fn_base(
|
|||
} && !fd.inputs.is_empty();
|
||||
|
||||
let mut args_last_line_contains_comment = false;
|
||||
let mut no_args_and_over_max_width = false;
|
||||
|
||||
if put_args_in_block {
|
||||
arg_indent = indent.block_indent(context.config);
|
||||
result.push_str(&arg_indent.to_string_with_newline(context.config));
|
||||
|
@ -2083,10 +2085,12 @@ fn rewrite_fn_base(
|
|||
.lines()
|
||||
.last()
|
||||
.map_or(false, |last_line| last_line.contains("//"));
|
||||
result.push(')');
|
||||
|
||||
if closing_paren_overflow_max_width || args_last_line_contains_comment {
|
||||
result.push_str(&indent.to_string_with_newline(context.config));
|
||||
no_args_and_over_max_width = true;
|
||||
}
|
||||
result.push(')');
|
||||
}
|
||||
|
||||
// Return type.
|
||||
|
@ -2126,7 +2130,9 @@ fn rewrite_fn_base(
|
|||
result.push_str(&indent.to_string_with_newline(context.config));
|
||||
indent
|
||||
} else {
|
||||
result.push(' ');
|
||||
if arg_str.len() != 0 || !no_args_and_over_max_width {
|
||||
result.push(' ');
|
||||
}
|
||||
Indent::new(indent.block_indent, last_line_width(&result))
|
||||
};
|
||||
|
||||
|
|
3
tests/source/issue-3278.rs
Normal file
3
tests/source/issue-3278.rs
Normal file
|
@ -0,0 +1,3 @@
|
|||
pub fn parse_conditional<'a, I: 'a>() -> impl Parser<Input = I, Output = Expr, PartialState = ()> + 'a
|
||||
where I: Stream<Item = char>
|
||||
{}
|
6
tests/target/issue-3278.rs
Normal file
6
tests/target/issue-3278.rs
Normal file
|
@ -0,0 +1,6 @@
|
|||
pub fn parse_conditional<'a, I: 'a>()
|
||||
-> impl Parser<Input = I, Output = Expr, PartialState = ()> + 'a
|
||||
where
|
||||
I: Stream<Item = char>,
|
||||
{
|
||||
}
|
|
@ -15,14 +15,14 @@ impl Foo {
|
|||
|
||||
// #1843
|
||||
#[allow(non_snake_case)]
|
||||
pub extern "C" fn Java_com_exonum_binding_storage_indices_ValueSetIndexProxy_nativeContainsByHash(
|
||||
) -> bool {
|
||||
pub extern "C" fn Java_com_exonum_binding_storage_indices_ValueSetIndexProxy_nativeContainsByHash()
|
||||
-> bool {
|
||||
false
|
||||
}
|
||||
|
||||
// #3009
|
||||
impl Something {
|
||||
fn my_function_name_is_way_to_long_but_used_as_a_case_study_or_an_example_its_fine(
|
||||
) -> Result<(), String> {
|
||||
fn my_function_name_is_way_to_long_but_used_as_a_case_study_or_an_example_its_fine()
|
||||
-> Result<(), String> {
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue