Merge pull request #895 from erikjohnston/fn_arg_block_incorrect_indent

Fix incorrect indent with fn_args_layout: Block
This commit is contained in:
Nick Cameron 2016-04-02 11:10:06 +13:00
commit c3cef52cde
7 changed files with 109 additions and 0 deletions

View File

@ -1339,6 +1339,7 @@ fn rewrite_fn_base(context: &RewriteContext,
result.push_str(&arg_str);
if context.config.fn_args_layout == StructLitStyle::Block {
result.push('\n');
result.push_str(&indent.to_string(context.config));
}
result.push(')');

View File

@ -34,3 +34,9 @@ fn foo(a: Aaaaaaaaaaaaaa, b: Bbbbbbbbbbbbbb) -> String where T: UUUUUUUUUUU {
fn bar(a: Aaaaaaaaaaaaaa, b: Bbbbbbbbbbbbbb, c: Cccccccccccccccccc, d: Dddddddddddddddd, e: Eeeeeeeeeeeeeee) -> String where T: UUUUUUUUUUU {
bar();
}
trait Test {
fn foo(a: u8) {}
fn bar(a: u8) -> String {}
}

View File

@ -17,3 +17,9 @@ fn foo(a: u8 /* Comment 1 */, b: u8 /* Comment 2 */) -> u8 {
fn foo(/* Comment 1 */ a: u8, /* Comment 2 */ b: u8) -> u8 {
bar()
}
trait Test {
fn foo(a: u8) {}
fn bar(a: u8) -> String {}
}

View File

@ -0,0 +1,24 @@
// rustfmt-fn_args_layout: Block
fn foo(a: Aaaaaaaaaaaaaa, b: Bbbbbbbbbbbbbb) {
foo();
}
fn bar(a: Aaaaaaaaaaaaaa, b: Bbbbbbbbbbbbbb, c: Cccccccccccccccccc, d: Dddddddddddddddd, e: Eeeeeeeeeeeeeee) {
bar();
}
fn foo(a: Aaaaaaaaaaaaaa, b: Bbbbbbbbbbbbbb) -> String {
foo();
}
fn bar(a: Aaaaaaaaaaaaaa, b: Bbbbbbbbbbbbbb, c: Cccccccccccccccccc, d: Dddddddddddddddd, e: Eeeeeeeeeeeeeee) -> String {
bar();
}
trait Test {
fn foo(a: u8) {}
fn bar(a: u8) -> String {}
}

View File

@ -68,3 +68,15 @@ fn bar(
where T: UUUUUUUUUUU {
bar();
}
trait Test {
fn foo(
a: u8
) {
}
fn bar(
a: u8
) -> String {
}
}

View File

@ -30,3 +30,17 @@ fn foo(
{
bar()
}
trait Test {
fn foo(
a: u8
)
{
}
fn bar(
a: u8
) -> String
{
}
}

View File

@ -0,0 +1,46 @@
// rustfmt-fn_args_layout: Block
fn foo(
a: Aaaaaaaaaaaaaa, b: Bbbbbbbbbbbbbb
) {
foo();
}
fn bar(
a: Aaaaaaaaaaaaaa,
b: Bbbbbbbbbbbbbb,
c: Cccccccccccccccccc,
d: Dddddddddddddddd,
e: Eeeeeeeeeeeeeee
) {
bar();
}
fn foo(
a: Aaaaaaaaaaaaaa, b: Bbbbbbbbbbbbbb
) -> String {
foo();
}
fn bar(
a: Aaaaaaaaaaaaaa,
b: Bbbbbbbbbbbbbb,
c: Cccccccccccccccccc,
d: Dddddddddddddddd,
e: Eeeeeeeeeeeeeee
) -> String {
bar();
}
trait Test {
fn foo(
a: u8
) {
}
fn bar(
a: u8
) -> String {
}
}