Fix long generic indent
This commit is contained in:
parent
4edc6f1a4e
commit
4c9dd747bf
@ -1290,12 +1290,13 @@ fn rewrite_fn_base(context: &RewriteContext,
|
||||
};
|
||||
|
||||
// Args.
|
||||
let (mut one_line_budget, multi_line_budget, mut arg_indent) =
|
||||
let (mut one_line_budget, mut multi_line_budget, mut arg_indent) =
|
||||
compute_budgets_for_args(context, &result, indent, ret_str_len, newline_brace);
|
||||
|
||||
if context.config.fn_args_layout == FnArgLayoutStyle::Block ||
|
||||
context.config.fn_args_layout == FnArgLayoutStyle::BlockAlways {
|
||||
arg_indent = indent.block_indent(context.config);
|
||||
multi_line_budget = context.config.max_width - arg_indent.width();
|
||||
}
|
||||
|
||||
debug!("rewrite_fn: one_line_budget: {}, multi_line_budget: {}, arg_indent: {:?}",
|
||||
@ -1569,6 +1570,8 @@ fn rewrite_args(context: &RewriteContext,
|
||||
_ => multi_line_budget,
|
||||
};
|
||||
|
||||
debug!("rewrite_args: budget: {}, tactic: {:?}", budget, tactic);
|
||||
|
||||
let end_with_newline = match context.config.fn_args_layout {
|
||||
FnArgLayoutStyle::Block | FnArgLayoutStyle::BlockAlways => true,
|
||||
_ => false,
|
||||
|
@ -1,4 +1,4 @@
|
||||
// rustfmt-fn_args_layout: Block
|
||||
// rustfmt-fn_args_layout: BlockAlways
|
||||
// rustfmt-where_indent: Inherit
|
||||
// rustfmt-fn_brace_style: PreferSameLine
|
||||
// Test different indents.
|
||||
|
@ -1,4 +1,4 @@
|
||||
// rustfmt-fn_args_layout: Block
|
||||
// rustfmt-fn_args_layout: BlockAlways
|
||||
// rustfmt-fn_args_density: Vertical
|
||||
// rustfmt-fn_arg_indent: Tabbed
|
||||
// rustfmt-fn_brace_style: AlwaysNextLine
|
||||
|
50
tests/source/fn-custom-8.rs
Normal file
50
tests/source/fn-custom-8.rs
Normal file
@ -0,0 +1,50 @@
|
||||
// rustfmt-fn_args_layout: Block
|
||||
// rustfmt-where_indent: Inherit
|
||||
// rustfmt-fn_brace_style: PreferSameLine
|
||||
// Test different indents.
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
fn foo(a: Aaaaaaaaaaaaaa, b: Bbbbbbbbbbbbbb) where T: UUUUUUUUUUU {
|
||||
foo();
|
||||
}
|
||||
|
||||
fn bar(a: Aaaaaaaaaaaaaa, b: Bbbbbbbbbbbbbb, c: Cccccccccccccccccc, d: Dddddddddddddddd, e: Eeeeeeeeeeeeeee) where T: UUUUUUUUUUU {
|
||||
bar();
|
||||
}
|
||||
|
||||
fn foo(a: Aaaaaaaaaaaaaa, b: Bbbbbbbbbbbbbb) -> String where T: UUUUUUUUUUU {
|
||||
foo();
|
||||
}
|
||||
|
||||
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 {
|
||||
|
||||
}
|
||||
|
||||
fn bar(a: u8) -> String where Foo: foooo, Bar: barrr {}
|
||||
}
|
@ -62,12 +62,16 @@ fn foo<L: Loooooooooooooooooooong, G: Geeeeeeeeeeneric, I: iiiiiiiiis, L: Looooo
|
||||
foo();
|
||||
}
|
||||
|
||||
fn foo<L: Loooooooooooooooooooong, G: Geeeeeeeeeeneric, I: iiiiiiiiis, L: Loooooooooooooooong>(a: Aaaaaaaaaaaaaaaaaaaa, b: Bbbbbbbbbbbbbbbbb, c: Cccccccccccccccccc, d: Dddddddddddddddd) {
|
||||
foo();
|
||||
}
|
||||
|
||||
trait Test {
|
||||
fn foo(a: u8) {}
|
||||
|
||||
fn bar(a: Aaaaaaaaaaaaaa, b: Bbbbbbbbbbbbbb, c: Cccccccccccccccccc, d: Dddddddddddddddd, e: Eeeeeeeeeeeeeee) -> String {}
|
||||
}
|
||||
|
||||
fn foo<L: Loooooooooooooooooooong, G: Geeeeeeeeeeneric, I: iiiiiiiiis, L: Loooooooooooooooong>(a: Aaaaaaaaaaaaaaaaaaaa, b: Bbbbbbbbbbbbbbbbb, c: Cccccccccccccccccc, d: Dddddddddddddddd) {
|
||||
foo();
|
||||
}
|
||||
|
||||
fn foo() -> (Looooooooooooooooooooooooooong, Reeeeeeeeeeeeeeeeeeeeeeeeeeeeeturn, iiiiiiiiiiiiiis, Loooooooooooooooooooooong) {
|
||||
foo();
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
// rustfmt-fn_args_layout: Block
|
||||
// rustfmt-fn_args_layout: BlockAlways
|
||||
// rustfmt-where_indent: Inherit
|
||||
// rustfmt-fn_brace_style: PreferSameLine
|
||||
// Test different indents.
|
||||
|
@ -1,4 +1,4 @@
|
||||
// rustfmt-fn_args_layout: Block
|
||||
// rustfmt-fn_args_layout: BlockAlways
|
||||
// rustfmt-fn_args_density: Vertical
|
||||
// rustfmt-fn_arg_indent: Tabbed
|
||||
// rustfmt-fn_brace_style: AlwaysNextLine
|
||||
|
74
tests/target/fn-custom-8.rs
Normal file
74
tests/target/fn-custom-8.rs
Normal file
@ -0,0 +1,74 @@
|
||||
// rustfmt-fn_args_layout: Block
|
||||
// rustfmt-where_indent: Inherit
|
||||
// rustfmt-fn_brace_style: PreferSameLine
|
||||
// Test different indents.
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
fn foo(a: Aaaaaaaaaaaaaa, b: Bbbbbbbbbbbbbb)
|
||||
where T: UUUUUUUUUUU {
|
||||
foo();
|
||||
}
|
||||
|
||||
fn bar(
|
||||
a: Aaaaaaaaaaaaaa,
|
||||
b: Bbbbbbbbbbbbbb,
|
||||
c: Cccccccccccccccccc,
|
||||
d: Dddddddddddddddd,
|
||||
e: Eeeeeeeeeeeeeee
|
||||
) where T: UUUUUUUUUUU {
|
||||
bar();
|
||||
}
|
||||
|
||||
fn foo(a: Aaaaaaaaaaaaaa, b: Bbbbbbbbbbbbbb) -> String
|
||||
where T: UUUUUUUUUUU {
|
||||
foo();
|
||||
}
|
||||
|
||||
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 {}
|
||||
|
||||
fn bar(a: u8) -> String
|
||||
where Foo: foooo,
|
||||
Bar: barrr {
|
||||
}
|
||||
}
|
@ -98,10 +98,6 @@ fn foo<L: Loooooooooooooooooooong, G: Geeeeeeeeeeneric, I: iiiiiiiiis, L: Looooo
|
||||
foo();
|
||||
}
|
||||
|
||||
fn foo<L: Loooooooooooooooooooong, G: Geeeeeeeeeeneric, I: iiiiiiiiis, L: Loooooooooooooooong>(a: Aaaaaaaaaaaaaaaaaaaa, b: Bbbbbbbbbbbbbbbbb, c: Cccccccccccccccccc, d: Dddddddddddddddd) {
|
||||
foo();
|
||||
}
|
||||
|
||||
trait Test {
|
||||
fn foo(a: u8) {}
|
||||
|
||||
@ -114,3 +110,21 @@ trait Test {
|
||||
) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
fn foo<L: Loooooooooooooooooooong, G: Geeeeeeeeeeneric, I: iiiiiiiiis, L: Loooooooooooooooong>(
|
||||
a: Aaaaaaaaaaaaaaaaaaaa,
|
||||
b: Bbbbbbbbbbbbbbbbb,
|
||||
c: Cccccccccccccccccc,
|
||||
d: Dddddddddddddddd
|
||||
) {
|
||||
foo();
|
||||
}
|
||||
|
||||
fn foo()
|
||||
-> (Looooooooooooooooooooooooooong,
|
||||
Reeeeeeeeeeeeeeeeeeeeeeeeeeeeeturn,
|
||||
iiiiiiiiiiiiiis,
|
||||
Loooooooooooooooooooooong)
|
||||
{
|
||||
foo();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user