Skip to content

Commit

Permalink
Organize vertical layout of function definition
Browse files Browse the repository at this point in the history
  • Loading branch information
Seiichi Uchida committed Jun 3, 2017
1 parent 9b7ba98 commit dd13761
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
30 changes: 17 additions & 13 deletions src/items.rs
Expand Up @@ -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 {
Expand Down
9 changes: 9 additions & 0 deletions tests/target/issue-1624.rs
@@ -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) {
}

0 comments on commit dd13761

Please sign in to comment.