mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-13 04:26:48 +00:00
Organize vertical layout of function definition
This commit is contained in:
parent
9b7ba980cf
commit
dd13761f85
30
src/items.rs
30
src/items.rs
@ -1622,24 +1622,28 @@ fn rewrite_fn_base(context: &RewriteContext,
|
||||
// Check if vertical layout was forced.
|
||||
if one_line_budget == 0 {
|
||||
if snuggle_angle_bracket {
|
||||
result.push_str("(");
|
||||
} else if context.config.fn_args_paren_newline() {
|
||||
result.push('\n');
|
||||
result.push_str(&arg_indent.to_string(context.config));
|
||||
arg_indent = arg_indent + 1; // extra space for `(`
|
||||
result.push('(');
|
||||
if context.config.spaces_within_parens() && fd.inputs.len() > 0 {
|
||||
result.push(' ')
|
||||
}
|
||||
} else {
|
||||
result.push_str("(\n");
|
||||
result.push_str(&arg_indent.to_string(context.config));
|
||||
if context.config.fn_args_paren_newline() {
|
||||
result.push('\n');
|
||||
result.push_str(&arg_indent.to_string(context.config));
|
||||
if context.config.fn_args_layout() == IndentStyle::Visual {
|
||||
arg_indent = arg_indent + 1; // extra space for `(`
|
||||
}
|
||||
result.push('(');
|
||||
} else {
|
||||
result.push_str("(");
|
||||
if context.config.fn_args_layout() == IndentStyle::Visual {
|
||||
result.push('\n');
|
||||
result.push_str(&arg_indent.to_string(context.config));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
result.push('(');
|
||||
if context.config.spaces_within_parens() && fd.inputs.len() > 0 {
|
||||
result.push(' ')
|
||||
}
|
||||
}
|
||||
if context.config.spaces_within_parens() && fd.inputs.len() > 0 && result.ends_with('(') {
|
||||
result.push(' ')
|
||||
}
|
||||
|
||||
if multi_line_ret_str {
|
||||
|
9
tests/target/issue-1624.rs
Normal file
9
tests/target/issue-1624.rs
Normal file
@ -0,0 +1,9 @@
|
||||
// rustfmt-fn_args_layout: Block
|
||||
// rustfmt-fn_args_paren_newline: false
|
||||
|
||||
// #1624
|
||||
pub unsafe fn some_long_function_name(
|
||||
arg1: Type1,
|
||||
arg2: Type2,
|
||||
) -> (SomeLongTypeName, AnotherLongTypeName, AnotherLongTypeName) {
|
||||
}
|
Loading…
Reference in New Issue
Block a user