Remove FnArgLayoutStyle::BlockAlways

This commit is contained in:
Nick Cameron 2017-03-20 11:35:53 +13:00
parent ce7b0aacd0
commit c986e895bb
9 changed files with 17 additions and 121 deletions

View File

@ -78,8 +78,6 @@ configuration_option_enum! { FnArgLayoutStyle:
Visual,
// Put args on one line if they fit, or start a new line with block indent.
Block,
// First line is on a new line and all lines align with block indent.
BlockAlways,
}
configuration_option_enum! { BlockIndentStyle:

View File

@ -331,8 +331,7 @@ pub fn rewrite_array<'a, I>(expr_iter: I,
};
let nested_shape = match context.config.array_layout {
FnArgLayoutStyle::Block |
FnArgLayoutStyle::BlockAlways => shape.block().block_indent(context.config.tab_spaces),
FnArgLayoutStyle::Block => shape.block().block_indent(context.config.tab_spaces),
FnArgLayoutStyle::Visual => {
try_opt!(shape.visual_indent(bracket_size).sub_width(bracket_size * 2))
}
@ -369,7 +368,6 @@ pub fn rewrite_array<'a, I>(expr_iter: I,
None => DefinitiveListTactic::Vertical,
}
}
FnArgLayoutStyle::BlockAlways => DefinitiveListTactic::Vertical,
FnArgLayoutStyle::Visual => {
if has_long_item || items.iter().any(ListItem::is_multiline) {
definitive_tactic(&items, ListTactic::HorizontalVertical, nested_shape.width)

View File

@ -1024,8 +1024,7 @@ fn format_tuple_struct(context: &RewriteContext,
// 1 = `(`
(ListTactic::HorizontalVertical, offset.block_only() + result.len() + 1)
}
FnArgLayoutStyle::Block |
FnArgLayoutStyle::BlockAlways => {
FnArgLayoutStyle::Block => {
(ListTactic::HorizontalVertical, offset.block_only().block_indent(&context.config))
}
};
@ -1513,8 +1512,7 @@ fn rewrite_fn_base(context: &RewriteContext,
let (mut one_line_budget, mut multi_line_budget, mut arg_indent) =
try_opt!(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 {
if context.config.fn_args_layout == FnArgLayoutStyle::Block {
arg_indent = indent.block_indent(context.config);
multi_line_budget = context.config.max_width - arg_indent.width();
}
@ -1569,7 +1567,6 @@ fn rewrite_fn_base(context: &RewriteContext,
let put_args_in_block = match context.config.fn_args_layout {
FnArgLayoutStyle::Block => multi_line_arg_str || generics_str.contains('\n'),
FnArgLayoutStyle::BlockAlways => true,
_ => false,
} && !fd.inputs.is_empty();
@ -1594,7 +1591,6 @@ fn rewrite_fn_base(context: &RewriteContext,
let ret_should_indent = match context.config.fn_args_layout {
// If our args are block layout then we surely must have space.
FnArgLayoutStyle::Block if put_args_in_block => false,
FnArgLayoutStyle::BlockAlways => false,
_ => {
// If we've already gone multi-line, or the return type would push over the max
// width, then put the return type on a new line. With the +1 for the signature
@ -1822,7 +1818,6 @@ fn rewrite_args(context: &RewriteContext,
let (trailing_comma, end_with_newline) = match context.config.fn_args_layout {
FnArgLayoutStyle::Block => (SeparatorTactic::Vertical, true),
FnArgLayoutStyle::BlockAlways => (SeparatorTactic::Always, true),
_ => (SeparatorTactic::Never, false),
};

View File

@ -1,4 +1,4 @@
// rustfmt-fn_args_layout: BlockAlways
// rustfmt-fn_args_layout: Block
// rustfmt-where_indent: Tabbed
// rustfmt-fn_brace_style: PreferSameLine
// Test different indents.

View File

@ -1,5 +1,5 @@
// rustfmt-normalize_comments: true
// rustfmt-fn_args_layout: BlockAlways
// rustfmt-fn_args_layout: Block
// rustfmt-fn_args_density: Vertical
// rustfmt-fn_arg_indent: Tabbed
// rustfmt-fn_brace_style: AlwaysNextLine

View File

@ -1,27 +0,0 @@
// rustfmt-fn_args_layout: BlockAlways
fn foo() {
foo();
}
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

@ -1,11 +1,9 @@
// rustfmt-fn_args_layout: BlockAlways
// rustfmt-fn_args_layout: Block
// rustfmt-where_indent: Tabbed
// rustfmt-fn_brace_style: PreferSameLine
// Test different indents.
fn foo(
a: Aaaaaaaaaaaaaa, b: Bbbbbbbbbbbbbb,
) {
fn foo(a: Aaaaaaaaaaaaaa, b: Bbbbbbbbbbbbbb) {
foo();
}
@ -19,9 +17,7 @@ fn bar(
bar();
}
fn foo(
a: Aaaaaaaaaaaaaa, b: Bbbbbbbbbbbbbb,
) -> String {
fn foo(a: Aaaaaaaaaaaaaa, b: Bbbbbbbbbbbbbb) -> String {
foo();
}
@ -35,9 +31,8 @@ fn bar(
bar();
}
fn foo(
a: Aaaaaaaaaaaaaa, b: Bbbbbbbbbbbbbb,
) where T: UUUUUUUUUUU {
fn foo(a: Aaaaaaaaaaaaaa, b: Bbbbbbbbbbbbbb)
where T: UUUUUUUUUUU {
foo();
}
@ -51,9 +46,7 @@ fn bar(
bar();
}
fn foo(
a: Aaaaaaaaaaaaaa, b: Bbbbbbbbbbbbbb,
) -> String
fn foo(a: Aaaaaaaaaaaaaa, b: Bbbbbbbbbbbbbb) -> String
where T: UUUUUUUUUUU {
foo();
}
@ -70,13 +63,7 @@ fn bar(
}
trait Test {
fn foo(
a: u8,
) {
}
fn foo(a: u8) {}
fn bar(
a: u8,
) -> String {
}
fn bar(a: u8) -> String {}
}

View File

@ -1,13 +1,11 @@
// rustfmt-normalize_comments: true
// rustfmt-fn_args_layout: BlockAlways
// rustfmt-fn_args_layout: Block
// rustfmt-fn_args_density: Vertical
// rustfmt-fn_arg_indent: Tabbed
// rustfmt-fn_brace_style: AlwaysNextLine
// Case with only one variable.
fn foo(
a: u8,
) -> u8
fn foo(a: u8,) -> u8
{
bar()
}
@ -33,15 +31,11 @@ fn foo(
}
trait Test {
fn foo(
a: u8,
)
fn foo(a: u8,)
{
}
fn bar(
a: u8,
) -> String
fn bar(a: u8,) -> String
{
}
}

View File

@ -1,49 +0,0 @@
// rustfmt-fn_args_layout: BlockAlways
fn foo() {
foo();
}
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 {
}
}