From c986e895bbe856ffafd6999cc1d4418330e47f86 Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Mon, 20 Mar 2017 11:35:53 +1300 Subject: [PATCH] Remove FnArgLayoutStyle::BlockAlways --- src/config.rs | 2 - src/expr.rs | 4 +- src/items.rs | 9 +--- tests/source/fn-custom-6.rs | 2 +- tests/source/fn-custom-7.rs | 2 +- tests/source/fn_args_layout-blockalways.rs | 27 ------------ tests/target/fn-custom-6.rs | 29 ++++--------- tests/target/fn-custom-7.rs | 14 ++----- tests/target/fn_args_layout-blockalways.rs | 49 ---------------------- 9 files changed, 17 insertions(+), 121 deletions(-) delete mode 100644 tests/source/fn_args_layout-blockalways.rs delete mode 100644 tests/target/fn_args_layout-blockalways.rs diff --git a/src/config.rs b/src/config.rs index ff9b7cd4d96f..317cc9218c79 100644 --- a/src/config.rs +++ b/src/config.rs @@ -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: diff --git a/src/expr.rs b/src/expr.rs index 7e85ca4ee344..3d6ec44b8c81 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -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) diff --git a/src/items.rs b/src/items.rs index 445959f63b0a..f2650494a822 100644 --- a/src/items.rs +++ b/src/items.rs @@ -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), }; diff --git a/tests/source/fn-custom-6.rs b/tests/source/fn-custom-6.rs index 5f464d930453..f7079a3a9cdd 100644 --- a/tests/source/fn-custom-6.rs +++ b/tests/source/fn-custom-6.rs @@ -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. diff --git a/tests/source/fn-custom-7.rs b/tests/source/fn-custom-7.rs index 1cbcd211808d..febe0c02db28 100644 --- a/tests/source/fn-custom-7.rs +++ b/tests/source/fn-custom-7.rs @@ -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 diff --git a/tests/source/fn_args_layout-blockalways.rs b/tests/source/fn_args_layout-blockalways.rs deleted file mode 100644 index d4bb00b91427..000000000000 --- a/tests/source/fn_args_layout-blockalways.rs +++ /dev/null @@ -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 {} -} diff --git a/tests/target/fn-custom-6.rs b/tests/target/fn-custom-6.rs index 8cd8d20f3609..4340e7ac827e 100644 --- a/tests/target/fn-custom-6.rs +++ b/tests/target/fn-custom-6.rs @@ -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 {} } diff --git a/tests/target/fn-custom-7.rs b/tests/target/fn-custom-7.rs index c0c1b9a8aa11..faa47a54060d 100644 --- a/tests/target/fn-custom-7.rs +++ b/tests/target/fn-custom-7.rs @@ -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 { } } diff --git a/tests/target/fn_args_layout-blockalways.rs b/tests/target/fn_args_layout-blockalways.rs deleted file mode 100644 index eb5caec65201..000000000000 --- a/tests/target/fn_args_layout-blockalways.rs +++ /dev/null @@ -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 { - } -}