From 5096cdff56e15e4b9127c67737d59d856b9bb83d Mon Sep 17 00:00:00 2001 From: topecongiro Date: Sat, 4 Nov 2017 22:45:09 +0900 Subject: [PATCH 1/5] Rename 'array_layout' to 'array_indent' --- Configurations.md | 10 +++++----- legacy-rustfmt.toml | 2 +- src/config.rs | 2 +- src/expr.rs | 10 +++++----- ...gs-array_horizontal_layout_threshold-1000-visual.rs | 2 +- tests/source/configs-array_layout-block.rs | 2 +- tests/source/configs-array_layout-visual.rs | 2 +- tests/source/configs-tab_spaces-2.rs | 2 +- tests/source/configs-tab_spaces-4.rs | 2 +- tests/source/expr-block.rs | 2 +- ...gs-array_horizontal_layout_threshold-1000-visual.rs | 2 +- tests/target/configs-array_layout-block.rs | 2 +- tests/target/configs-array_layout-visual.rs | 2 +- tests/target/configs-tab_spaces-2.rs | 2 +- tests/target/configs-tab_spaces-4.rs | 2 +- tests/target/expr-block.rs | 2 +- 16 files changed, 24 insertions(+), 24 deletions(-) diff --git a/Configurations.md b/Configurations.md index 46d94eb1474..63c6d78b961 100644 --- a/Configurations.md +++ b/Configurations.md @@ -5,7 +5,7 @@ Rustfmt is designed to be very configurable. You can create a TOML file called ` A possible content of `rustfmt.toml` or `.rustfmt.toml` might look like this: ```toml -array_layout = "Block" +array_indent = "Block" array_width = 80 reorder_imported_names = true ``` @@ -22,7 +22,7 @@ Use this option to prevent a huge array from being vertically formatted. - **Default value**: `0` - **Possible values**: any positive integer -**Note:** A value of `0` results in [`array_layout`](#array_layout) being applied regardless of a line's width. +**Note:** A value of `0` results in [`array_indent`](#array_indent) being applied regardless of a line's width. #### `0` (default): @@ -50,7 +50,7 @@ let a = vec![ ]; ``` -## `array_layout` +## `array_indent` Indent on arrays @@ -90,7 +90,7 @@ Maximum width of an array literal before falling back to vertical formatting - **Default value**: `60` - **Possible values**: any positive integer -**Note:** A value of `0` results in [`array_layout`](#array_layout) being applied regardless of a line's width. +**Note:** A value of `0` results in [`array_indent`](#array_indent) being applied regardless of a line's width. #### Lines shorter than `array_width`: ```rust @@ -98,7 +98,7 @@ let lorem = vec!["ipsum", "dolor", "sit", "amet", "consectetur", "adipiscing", " ``` #### Lines longer than `array_width`: -See [`array_layout`](#array_layout). +See [`array_indent`](#array_indent). ## `attributes_on_same_line_as_field` diff --git a/legacy-rustfmt.toml b/legacy-rustfmt.toml index da1da764b2e..8442f314197 100644 --- a/legacy-rustfmt.toml +++ b/legacy-rustfmt.toml @@ -1,5 +1,5 @@ fn_args_layout = "Visual" -array_layout = "Visual" +array_indent = "Visual" control_style = "Legacy" where_style = "Legacy" generics_indent = "Visual" diff --git a/src/config.rs b/src/config.rs index 302719e72e3..a223e2da68b 100644 --- a/src/config.rs +++ b/src/config.rs @@ -561,7 +561,7 @@ create_config! { fn_args_density: Density, Density::Tall, false, "Argument density in functions"; fn_args_layout: IndentStyle, IndentStyle::Block, false, "Layout of function arguments and tuple structs"; - array_layout: IndentStyle, IndentStyle::Block, false, "Indent on arrays"; + array_indent: IndentStyle, IndentStyle::Block, false, "Indent on arrays"; array_width: usize, 60, false, "Maximum width of an array literal before falling back to vertical formatting"; array_horizontal_layout_threshold: usize, 0, false, diff --git a/src/expr.rs b/src/expr.rs index 09b9a4e622e..9888ffc3e00 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -419,7 +419,7 @@ where 1 // "[" }; - let nested_shape = match context.config.array_layout() { + let nested_shape = match context.config.array_indent() { IndentStyle::Block => shape .block() .block_indent(context.config.tab_spaces()) @@ -454,7 +454,7 @@ where .iter() .any(|li| li.item.as_ref().map(|s| s.len() > 10).unwrap_or(false)); - let mut tactic = match context.config.array_layout() { + let mut tactic = match context.config.array_indent() { IndentStyle::Block => { // FIXME wrong shape in one-line case match shape.width.checked_sub(2 * bracket_size) { @@ -477,7 +477,7 @@ where DefinitiveListTactic::Mixed }, }; - let ends_with_newline = tactic.ends_with_newline(context.config.array_layout()); + let ends_with_newline = tactic.ends_with_newline(context.config.array_indent()); if context.config.array_horizontal_layout_threshold() > 0 && items.len() > context.config.array_horizontal_layout_threshold() { @@ -489,7 +489,7 @@ where separator: ",", trailing_separator: if trailing_comma { SeparatorTactic::Always - } else if context.inside_macro || context.config.array_layout() == IndentStyle::Visual { + } else if context.inside_macro || context.config.array_indent() == IndentStyle::Visual { SeparatorTactic::Never } else { SeparatorTactic::Vertical @@ -502,7 +502,7 @@ where }; let list_str = write_list(&items, &fmt)?; - let result = if context.config.array_layout() == IndentStyle::Visual + let result = if context.config.array_indent() == IndentStyle::Visual || tactic == DefinitiveListTactic::Horizontal { if context.config.spaces_within_square_brackets() && !list_str.is_empty() { diff --git a/tests/source/configs-array_horizontal_layout_threshold-1000-visual.rs b/tests/source/configs-array_horizontal_layout_threshold-1000-visual.rs index 877d63194e8..84cfb06bced 100644 --- a/tests/source/configs-array_horizontal_layout_threshold-1000-visual.rs +++ b/tests/source/configs-array_horizontal_layout_threshold-1000-visual.rs @@ -1,5 +1,5 @@ // rustfmt-array_horizontal_layout_threshold: 1000 -// rustfmt-array_layout: Visual +// rustfmt-array_indent: Visual const ARRAY: [u8; 2048] = [99, 72, 48, 104, 44, 112, 38, 62, 40, 93, 23, 24, 32, 21, 102, 76, 65, 29, 116, diff --git a/tests/source/configs-array_layout-block.rs b/tests/source/configs-array_layout-block.rs index 02f38a836c3..7aefa36c187 100644 --- a/tests/source/configs-array_layout-block.rs +++ b/tests/source/configs-array_layout-block.rs @@ -1,4 +1,4 @@ -// rustfmt-array_layout: Block +// rustfmt-array_indent: Block // Array layout fn main() { diff --git a/tests/source/configs-array_layout-visual.rs b/tests/source/configs-array_layout-visual.rs index fa0d33a7edf..f448e9607d7 100644 --- a/tests/source/configs-array_layout-visual.rs +++ b/tests/source/configs-array_layout-visual.rs @@ -1,4 +1,4 @@ -// rustfmt-array_layout: Visual +// rustfmt-array_indent: Visual // Array layout fn main() { diff --git a/tests/source/configs-tab_spaces-2.rs b/tests/source/configs-tab_spaces-2.rs index 5caf51bf234..cd3d601e1b6 100644 --- a/tests/source/configs-tab_spaces-2.rs +++ b/tests/source/configs-tab_spaces-2.rs @@ -1,6 +1,6 @@ // rustfmt-tab_spaces: 2 // rustfmt-max_width: 30 -// rustfmt-array_layout: Block +// rustfmt-array_indent: Block // Tab spaces fn lorem() { diff --git a/tests/source/configs-tab_spaces-4.rs b/tests/source/configs-tab_spaces-4.rs index 470849e769b..3a18f9be0ee 100644 --- a/tests/source/configs-tab_spaces-4.rs +++ b/tests/source/configs-tab_spaces-4.rs @@ -1,6 +1,6 @@ // rustfmt-tab_spaces: 4 // rustfmt-max_width: 30 -// rustfmt-array_layout: Block +// rustfmt-array_indent: Block // Tab spaces fn lorem() { diff --git a/tests/source/expr-block.rs b/tests/source/expr-block.rs index 18706783fb4..2b899151535 100644 --- a/tests/source/expr-block.rs +++ b/tests/source/expr-block.rs @@ -1,4 +1,4 @@ -// rustfmt-array_layout: Block +// rustfmt-array_indent: Block // rustfmt-fn_call_style: Block // rustfmt-control_style: Rfc // Test expressions with block formatting. diff --git a/tests/target/configs-array_horizontal_layout_threshold-1000-visual.rs b/tests/target/configs-array_horizontal_layout_threshold-1000-visual.rs index 1f3dced2943..a4a2f6a3d2c 100644 --- a/tests/target/configs-array_horizontal_layout_threshold-1000-visual.rs +++ b/tests/target/configs-array_horizontal_layout_threshold-1000-visual.rs @@ -1,5 +1,5 @@ // rustfmt-array_horizontal_layout_threshold: 1000 -// rustfmt-array_layout: Visual +// rustfmt-array_indent: Visual const ARRAY: [u8; 2048] = [99, 72, 48, 104, 44, 112, 38, 62, 40, 93, 23, 24, 32, 21, 102, 76, 65, 29, 116, 21, 18, 37, diff --git a/tests/target/configs-array_layout-block.rs b/tests/target/configs-array_layout-block.rs index a95f808978a..c6c22096759 100644 --- a/tests/target/configs-array_layout-block.rs +++ b/tests/target/configs-array_layout-block.rs @@ -1,4 +1,4 @@ -// rustfmt-array_layout: Block +// rustfmt-array_indent: Block // Array layout fn main() { diff --git a/tests/target/configs-array_layout-visual.rs b/tests/target/configs-array_layout-visual.rs index 07b5ae088e6..bd15f2a3737 100644 --- a/tests/target/configs-array_layout-visual.rs +++ b/tests/target/configs-array_layout-visual.rs @@ -1,4 +1,4 @@ -// rustfmt-array_layout: Visual +// rustfmt-array_indent: Visual // Array layout fn main() { diff --git a/tests/target/configs-tab_spaces-2.rs b/tests/target/configs-tab_spaces-2.rs index 73b593d8fe1..3bbb4c05290 100644 --- a/tests/target/configs-tab_spaces-2.rs +++ b/tests/target/configs-tab_spaces-2.rs @@ -1,6 +1,6 @@ // rustfmt-tab_spaces: 2 // rustfmt-max_width: 30 -// rustfmt-array_layout: Block +// rustfmt-array_indent: Block // Tab spaces fn lorem() { diff --git a/tests/target/configs-tab_spaces-4.rs b/tests/target/configs-tab_spaces-4.rs index f4f6cd78d95..c8c802c9db5 100644 --- a/tests/target/configs-tab_spaces-4.rs +++ b/tests/target/configs-tab_spaces-4.rs @@ -1,6 +1,6 @@ // rustfmt-tab_spaces: 4 // rustfmt-max_width: 30 -// rustfmt-array_layout: Block +// rustfmt-array_indent: Block // Tab spaces fn lorem() { diff --git a/tests/target/expr-block.rs b/tests/target/expr-block.rs index 329890e8b12..75d15418ba2 100644 --- a/tests/target/expr-block.rs +++ b/tests/target/expr-block.rs @@ -1,4 +1,4 @@ -// rustfmt-array_layout: Block +// rustfmt-array_indent: Block // rustfmt-fn_call_style: Block // rustfmt-control_style: Rfc // Test expressions with block formatting. From 55c2000d947516798dac4ce6055fb1c470b09718 Mon Sep 17 00:00:00 2001 From: topecongiro Date: Sat, 4 Nov 2017 22:45:47 +0900 Subject: [PATCH 2/5] Rename 'fn_args_layout' to 'fn_args_indent' --- Configurations.md | 2 +- legacy-rustfmt.toml | 2 +- src/config.rs | 2 +- src/items.rs | 20 +++++++++---------- src/types.rs | 4 ++-- tests/config/small_tabs.toml | 2 +- tests/source/big-impl-rfc.rs | 2 +- tests/source/configs-fn_args_layout-block.rs | 2 +- tests/source/configs-fn_args_layout-visual.rs | 2 +- tests/source/fn-custom-2.rs | 2 +- tests/source/fn-custom-3.rs | 2 +- tests/source/fn-custom-6.rs | 2 +- tests/source/fn-custom-7.rs | 2 +- tests/source/fn-custom-8.rs | 2 +- tests/source/fn_args_layout-block.rs | 2 +- tests/source/issue-1278.rs | 2 +- tests/source/where-clause-rfc.rs | 2 +- tests/target/big-impl-rfc.rs | 2 +- tests/target/configs-fn_args_layout-block.rs | 2 +- tests/target/configs-fn_args_layout-visual.rs | 2 +- tests/target/fn-custom-2.rs | 2 +- tests/target/fn-custom-3.rs | 2 +- tests/target/fn-custom-6.rs | 2 +- tests/target/fn-custom-7.rs | 2 +- tests/target/fn-custom-8.rs | 2 +- tests/target/fn_args_layout-block.rs | 2 +- tests/target/issue-1278.rs | 2 +- tests/target/issue-1624.rs | 2 +- tests/target/where-clause-rfc.rs | 2 +- 29 files changed, 39 insertions(+), 39 deletions(-) diff --git a/Configurations.md b/Configurations.md index 63c6d78b961..f5d2cfa1df0 100644 --- a/Configurations.md +++ b/Configurations.md @@ -614,7 +614,7 @@ trait Lorem { } ``` -## `fn_args_layout` +## `fn_args_indent` Layout of function arguments and tuple structs diff --git a/legacy-rustfmt.toml b/legacy-rustfmt.toml index 8442f314197..617791a2d25 100644 --- a/legacy-rustfmt.toml +++ b/legacy-rustfmt.toml @@ -1,4 +1,4 @@ -fn_args_layout = "Visual" +fn_args_indent = "Visual" array_indent = "Visual" control_style = "Legacy" where_style = "Legacy" diff --git a/src/config.rs b/src/config.rs index a223e2da68b..d80019b998b 100644 --- a/src/config.rs +++ b/src/config.rs @@ -559,7 +559,7 @@ create_config! { "Location of return type in function declaration"; fn_args_paren_newline: bool, false, false, "If function argument parenthesis goes on a newline"; fn_args_density: Density, Density::Tall, false, "Argument density in functions"; - fn_args_layout: IndentStyle, IndentStyle::Block, false, + fn_args_indent: IndentStyle, IndentStyle::Block, false, "Layout of function arguments and tuple structs"; array_indent: IndentStyle, IndentStyle::Block, false, "Indent on arrays"; array_width: usize, 60, false, diff --git a/src/items.rs b/src/items.rs index 8adfe080a2c..83f74374e32 100644 --- a/src/items.rs +++ b/src/items.rs @@ -933,8 +933,8 @@ pub fn format_trait(context: &RewriteContext, item: &ast::Item, offset: Indent) let has_body = !trait_items.is_empty(); let where_density = if (context.config.where_density() == Density::Compressed - && (!result.contains('\n') || context.config.fn_args_layout() == IndentStyle::Block)) - || (context.config.fn_args_layout() == IndentStyle::Block && result.is_empty()) + && (!result.contains('\n') || context.config.fn_args_indent() == IndentStyle::Block)) + || (context.config.fn_args_indent() == IndentStyle::Block && result.is_empty()) || (context.config.where_density() == Density::CompressedIfEmpty && !has_body && !result.contains('\n')) { @@ -1746,13 +1746,13 @@ fn rewrite_fn_base( } else 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 { + if context.config.fn_args_indent() == IndentStyle::Visual { arg_indent = arg_indent + 1; // extra space for `(` } result.push('('); } else { result.push_str("("); - if context.config.fn_args_layout() == IndentStyle::Visual { + if context.config.fn_args_indent() == IndentStyle::Visual { result.push('\n'); result.push_str(&arg_indent.to_string(context.config)); } @@ -1805,7 +1805,7 @@ fn rewrite_fn_base( generics_str.contains('\n'), )?; - let put_args_in_block = match context.config.fn_args_layout() { + let put_args_in_block = match context.config.fn_args_indent() { IndentStyle::Block => arg_str.contains('\n') || arg_str.len() > one_line_budget, _ => false, } && !fd.inputs.is_empty(); @@ -1846,7 +1846,7 @@ fn rewrite_fn_base( // Return type. if let ast::FunctionRetTy::Ty(..) = fd.output { - let ret_should_indent = match context.config.fn_args_layout() { + let ret_should_indent = match context.config.fn_args_indent() { // If our args are block layout then we surely must have space. IndentStyle::Block if put_args_in_block || fd.inputs.is_empty() => false, _ if args_last_line_contains_comment => false, @@ -2131,7 +2131,7 @@ fn rewrite_args( .and_then(|item| item.post_comment.as_ref()) .map_or(false, |s| s.trim().starts_with("//")); - let (indent, trailing_comma) = match context.config.fn_args_layout() { + let (indent, trailing_comma) = match context.config.fn_args_indent() { IndentStyle::Block if fits_in_one_line => { (indent.block_indent(context.config), SeparatorTactic::Never) } @@ -2168,7 +2168,7 @@ fn rewrite_args( }, separator_place: SeparatorPlace::Back, shape: Shape::legacy(budget, indent), - ends_with_newline: tactic.ends_with_newline(context.config.fn_args_layout()), + ends_with_newline: tactic.ends_with_newline(context.config.fn_args_indent()), preserve_newline: true, config: context.config, }; @@ -2218,7 +2218,7 @@ fn compute_budgets_for_args( if one_line_budget > 0 { // 4 = "() {".len() - let (indent, multi_line_budget) = match context.config.fn_args_layout() { + let (indent, multi_line_budget) = match context.config.fn_args_indent() { IndentStyle::Block => { let indent = indent.block_indent(context.config); (indent, context.budget(indent.width() + 1)) @@ -2236,7 +2236,7 @@ fn compute_budgets_for_args( // Didn't work. we must force vertical layout and put args on a newline. let new_indent = indent.block_indent(context.config); - let used_space = match context.config.fn_args_layout() { + let used_space = match context.config.fn_args_indent() { // 1 = `,` IndentStyle::Block => new_indent.width() + 1, // Account for `)` and possibly ` {`. diff --git a/src/types.rs b/src/types.rs index 4bd942d21c9..e3f97cc6b70 100644 --- a/src/types.rs +++ b/src/types.rs @@ -302,7 +302,7 @@ where // 2 for () let budget = shape.width.checked_sub(2)?; // 1 for ( - let offset = match context.config.fn_args_layout() { + let offset = match context.config.fn_args_indent() { IndentStyle::Block => { shape .block() @@ -364,7 +364,7 @@ where let list_str = write_list(&item_vec, &fmt)?; - let ty_shape = match context.config.fn_args_layout() { + let ty_shape = match context.config.fn_args_indent() { IndentStyle::Block => shape.block().block_indent(context.config.tab_spaces()), IndentStyle::Visual => shape.block_left(4)?, }; diff --git a/tests/config/small_tabs.toml b/tests/config/small_tabs.toml index a682a88e811..f6a972c46b6 100644 --- a/tests/config/small_tabs.toml +++ b/tests/config/small_tabs.toml @@ -6,7 +6,7 @@ fn_brace_style = "SameLineWhere" fn_return_indent = "WithArgs" fn_args_paren_newline = true fn_args_density = "Tall" -fn_args_layout = "Visual" +fn_args_indent = "Visual" where_density = "Tall" where_layout = "Vertical" where_pred_indent = "Visual" diff --git a/tests/source/big-impl-rfc.rs b/tests/source/big-impl-rfc.rs index 2f04ee1ef92..2b3928f431f 100644 --- a/tests/source/big-impl-rfc.rs +++ b/tests/source/big-impl-rfc.rs @@ -1,4 +1,4 @@ -// rustfmt-fn_args_layout: Block +// rustfmt-fn_args_indent: Block // rustfmt-fn_call_style: Block // rustfmt-generics_indent: Block // rustfmt-where_style: Rfc diff --git a/tests/source/configs-fn_args_layout-block.rs b/tests/source/configs-fn_args_layout-block.rs index 28d1dffe6b3..169a538d70d 100644 --- a/tests/source/configs-fn_args_layout-block.rs +++ b/tests/source/configs-fn_args_layout-block.rs @@ -1,4 +1,4 @@ -// rustfmt-fn_args_layout: Block +// rustfmt-fn_args_indent: Block // Function arguments layout fn lorem() {} diff --git a/tests/source/configs-fn_args_layout-visual.rs b/tests/source/configs-fn_args_layout-visual.rs index e0af153f982..adc1466bffc 100644 --- a/tests/source/configs-fn_args_layout-visual.rs +++ b/tests/source/configs-fn_args_layout-visual.rs @@ -1,4 +1,4 @@ -// rustfmt-fn_args_layout: Visual +// rustfmt-fn_args_indent: Visual // Function arguments layout fn lorem() {} diff --git a/tests/source/fn-custom-2.rs b/tests/source/fn-custom-2.rs index 8c6813b054f..bdbbb45aaa0 100644 --- a/tests/source/fn-custom-2.rs +++ b/tests/source/fn-custom-2.rs @@ -1,4 +1,4 @@ -// rustfmt-fn_args_layout: Block +// rustfmt-fn_args_indent: Block // rustfmt-generics_indent: Block // rustfmt-where_layout: Mixed // Test different indents. diff --git a/tests/source/fn-custom-3.rs b/tests/source/fn-custom-3.rs index 38c7839a49a..2d05b1138f2 100644 --- a/tests/source/fn-custom-3.rs +++ b/tests/source/fn-custom-3.rs @@ -1,4 +1,4 @@ -// rustfmt-fn_args_layout: Block +// rustfmt-fn_args_indent: Block // rustfmt-generics_indent: Block // rustfmt-where_layout: HorizontalVertical // Test different indents. diff --git a/tests/source/fn-custom-6.rs b/tests/source/fn-custom-6.rs index c056985c796..b8677e4bbec 100644 --- a/tests/source/fn-custom-6.rs +++ b/tests/source/fn-custom-6.rs @@ -1,4 +1,4 @@ -// rustfmt-fn_args_layout: Block +// rustfmt-fn_args_indent: Block // 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 6ebf4236423..fceb4152575 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: Block +// rustfmt-fn_args_indent: Block // rustfmt-fn_args_density: Vertical // rustfmt-fn_brace_style: AlwaysNextLine diff --git a/tests/source/fn-custom-8.rs b/tests/source/fn-custom-8.rs index 0855ca1058f..fbc411919c7 100644 --- a/tests/source/fn-custom-8.rs +++ b/tests/source/fn-custom-8.rs @@ -1,4 +1,4 @@ -// rustfmt-fn_args_layout: Block +// rustfmt-fn_args_indent: Block // rustfmt-fn_brace_style: PreferSameLine // Test different indents. diff --git a/tests/source/fn_args_layout-block.rs b/tests/source/fn_args_layout-block.rs index be22369ab8c..4368274cc84 100644 --- a/tests/source/fn_args_layout-block.rs +++ b/tests/source/fn_args_layout-block.rs @@ -1,5 +1,5 @@ // rustfmt-normalize_comments: true -// rustfmt-fn_args_layout: Block +// rustfmt-fn_args_indent: Block fn foo() { foo(); diff --git a/tests/source/issue-1278.rs b/tests/source/issue-1278.rs index 1a458060bdd..d199773c834 100644 --- a/tests/source/issue-1278.rs +++ b/tests/source/issue-1278.rs @@ -1,4 +1,4 @@ -// rustfmt-fn_args_layout = "block" +// rustfmt-fn_args_indent = "block" #![feature(pub_restricted)] diff --git a/tests/source/where-clause-rfc.rs b/tests/source/where-clause-rfc.rs index 678b060602e..7dc5e87a9fe 100644 --- a/tests/source/where-clause-rfc.rs +++ b/tests/source/where-clause-rfc.rs @@ -1,4 +1,4 @@ -// rustfmt-fn_args_layout: Block +// rustfmt-fn_args_indent: Block // rustfmt-where_style: Rfc fn reflow_list_node_with_rule(node: &CompoundNode, rule: &Rule, args: &[Arg], shape: &Shape) where T: FOo, U: Bar { diff --git a/tests/target/big-impl-rfc.rs b/tests/target/big-impl-rfc.rs index da5ab03fd5e..5ce1613d23b 100644 --- a/tests/target/big-impl-rfc.rs +++ b/tests/target/big-impl-rfc.rs @@ -1,4 +1,4 @@ -// rustfmt-fn_args_layout: Block +// rustfmt-fn_args_indent: Block // rustfmt-fn_call_style: Block // rustfmt-generics_indent: Block // rustfmt-where_style: Rfc diff --git a/tests/target/configs-fn_args_layout-block.rs b/tests/target/configs-fn_args_layout-block.rs index 05d5d79a7e3..407a078596d 100644 --- a/tests/target/configs-fn_args_layout-block.rs +++ b/tests/target/configs-fn_args_layout-block.rs @@ -1,4 +1,4 @@ -// rustfmt-fn_args_layout: Block +// rustfmt-fn_args_indent: Block // Function arguments layout fn lorem() {} diff --git a/tests/target/configs-fn_args_layout-visual.rs b/tests/target/configs-fn_args_layout-visual.rs index 778d6d4fc03..fedea41662a 100644 --- a/tests/target/configs-fn_args_layout-visual.rs +++ b/tests/target/configs-fn_args_layout-visual.rs @@ -1,4 +1,4 @@ -// rustfmt-fn_args_layout: Visual +// rustfmt-fn_args_indent: Visual // Function arguments layout fn lorem() {} diff --git a/tests/target/fn-custom-2.rs b/tests/target/fn-custom-2.rs index 430ffeb9fb7..cec0b29854f 100644 --- a/tests/target/fn-custom-2.rs +++ b/tests/target/fn-custom-2.rs @@ -1,4 +1,4 @@ -// rustfmt-fn_args_layout: Block +// rustfmt-fn_args_indent: Block // rustfmt-generics_indent: Block // rustfmt-where_layout: Mixed // Test different indents. diff --git a/tests/target/fn-custom-3.rs b/tests/target/fn-custom-3.rs index 655f1f1dc5b..633ab05030d 100644 --- a/tests/target/fn-custom-3.rs +++ b/tests/target/fn-custom-3.rs @@ -1,4 +1,4 @@ -// rustfmt-fn_args_layout: Block +// rustfmt-fn_args_indent: Block // rustfmt-generics_indent: Block // rustfmt-where_layout: HorizontalVertical // Test different indents. diff --git a/tests/target/fn-custom-6.rs b/tests/target/fn-custom-6.rs index 9a2d8d8981a..f7bf2f04eaf 100644 --- a/tests/target/fn-custom-6.rs +++ b/tests/target/fn-custom-6.rs @@ -1,4 +1,4 @@ -// rustfmt-fn_args_layout: Block +// rustfmt-fn_args_indent: Block // rustfmt-fn_brace_style: PreferSameLine // Test different indents. diff --git a/tests/target/fn-custom-7.rs b/tests/target/fn-custom-7.rs index 1a134128d2b..b9f1820d066 100644 --- a/tests/target/fn-custom-7.rs +++ b/tests/target/fn-custom-7.rs @@ -1,5 +1,5 @@ // rustfmt-normalize_comments: true -// rustfmt-fn_args_layout: Block +// rustfmt-fn_args_indent: Block // rustfmt-fn_args_density: Vertical // rustfmt-fn_brace_style: AlwaysNextLine diff --git a/tests/target/fn-custom-8.rs b/tests/target/fn-custom-8.rs index 854f4231480..78880206f34 100644 --- a/tests/target/fn-custom-8.rs +++ b/tests/target/fn-custom-8.rs @@ -1,4 +1,4 @@ -// rustfmt-fn_args_layout: Block +// rustfmt-fn_args_indent: Block // rustfmt-fn_brace_style: PreferSameLine // Test different indents. diff --git a/tests/target/fn_args_layout-block.rs b/tests/target/fn_args_layout-block.rs index c8847768e13..afe453ca233 100644 --- a/tests/target/fn_args_layout-block.rs +++ b/tests/target/fn_args_layout-block.rs @@ -1,5 +1,5 @@ // rustfmt-normalize_comments: true -// rustfmt-fn_args_layout: Block +// rustfmt-fn_args_indent: Block fn foo() { foo(); diff --git a/tests/target/issue-1278.rs b/tests/target/issue-1278.rs index 1a458060bdd..d199773c834 100644 --- a/tests/target/issue-1278.rs +++ b/tests/target/issue-1278.rs @@ -1,4 +1,4 @@ -// rustfmt-fn_args_layout = "block" +// rustfmt-fn_args_indent = "block" #![feature(pub_restricted)] diff --git a/tests/target/issue-1624.rs b/tests/target/issue-1624.rs index dcdb18611a6..a41fff2e750 100644 --- a/tests/target/issue-1624.rs +++ b/tests/target/issue-1624.rs @@ -1,4 +1,4 @@ -// rustfmt-fn_args_layout: Block +// rustfmt-fn_args_indent: Block // rustfmt-fn_args_paren_newline: false // #1624 diff --git a/tests/target/where-clause-rfc.rs b/tests/target/where-clause-rfc.rs index f52cf3e220e..bf3a93e27fb 100644 --- a/tests/target/where-clause-rfc.rs +++ b/tests/target/where-clause-rfc.rs @@ -1,4 +1,4 @@ -// rustfmt-fn_args_layout: Block +// rustfmt-fn_args_indent: Block // rustfmt-where_style: Rfc fn reflow_list_node_with_rule(node: &CompoundNode, rule: &Rule, args: &[Arg], shape: &Shape) From d5d874099393203365f6f42cd29828c403d94660 Mon Sep 17 00:00:00 2001 From: topecongiro Date: Sat, 4 Nov 2017 22:46:40 +0900 Subject: [PATCH 3/5] Rename 'fn_call_style' to 'fn_call_indent' --- Configurations.md | 8 ++++---- legacy-rustfmt.toml | 2 +- src/config.rs | 2 +- src/expr.rs | 8 ++++---- src/rewrite.rs | 2 +- src/types.rs | 2 +- tests/source/big-impl-rfc.rs | 2 +- tests/source/closure-block-inside-macro.rs | 2 +- .../source/configs-fn_call_style-block-trailing-comma.rs | 2 +- tests/source/configs-fn_call_style-block.rs | 2 +- .../source/configs-fn_call_style-visual-trailing-comma.rs | 2 +- tests/source/configs-fn_call_style-visual.rs | 2 +- tests/source/configs-fn_call_width-zero.rs | 2 +- tests/source/expr-block.rs | 2 +- tests/target/big-impl-rfc.rs | 2 +- tests/target/closure-block-inside-macro.rs | 2 +- tests/target/configs-combine_control_expr-false.rs | 2 +- tests/target/configs-combine_control_expr-true.rs | 2 +- tests/target/configs-fn_call_style-block-tab_spaces-2.rs | 2 +- .../target/configs-fn_call_style-block-trailing-comma.rs | 2 +- tests/target/configs-fn_call_style-block.rs | 2 +- .../target/configs-fn_call_style-visual-trailing-comma.rs | 2 +- tests/target/configs-fn_call_style-visual.rs | 2 +- tests/target/configs-fn_call_width-zero.rs | 2 +- tests/target/expr-block.rs | 2 +- 25 files changed, 31 insertions(+), 31 deletions(-) diff --git a/Configurations.md b/Configurations.md index f5d2cfa1df0..ae50daf7211 100644 --- a/Configurations.md +++ b/Configurations.md @@ -298,7 +298,7 @@ lorem_ipsum(|| { }); ``` -**Note**: This option only takes effect when `fn_call_style` is set to `"Visual"`. +**Note**: This option only takes effect when `fn_call_indent` is set to `"Visual"`. ## `combine_control_expr` @@ -758,7 +758,7 @@ where } ``` -## `fn_call_style` +## `fn_call_indent` Indentation for function calls, etc. @@ -809,7 +809,7 @@ lorem("lorem", "ipsum", "dolor", "sit", "amet", "consectetur", "adipiscing", "el #### Function call longer than `fn_call_width`: -See [`fn_call_style`](#fn_call_style). +See [`fn_call_indent`](#fn_call_indent). ## `fn_empty_single_line` @@ -874,7 +874,7 @@ fn lorem(ipsum: Ipsum, ``` -**Note**: This option only takes effect when `fn_call_style` is set to `"Visual"`. +**Note**: This option only takes effect when `fn_call_indent` is set to `"Visual"`. ## `fn_single_line` diff --git a/legacy-rustfmt.toml b/legacy-rustfmt.toml index 617791a2d25..6adaf36b6b3 100644 --- a/legacy-rustfmt.toml +++ b/legacy-rustfmt.toml @@ -3,6 +3,6 @@ array_indent = "Visual" control_style = "Legacy" where_style = "Legacy" generics_indent = "Visual" -fn_call_style = "Visual" +fn_call_indent = "Visual" combine_control_expr = false fn_args_paren_newline = true diff --git a/src/config.rs b/src/config.rs index d80019b998b..a0d1dda2126 100644 --- a/src/config.rs +++ b/src/config.rs @@ -581,7 +581,7 @@ create_config! { struct_lit_style: IndentStyle, IndentStyle::Block, false, "Style of struct definition"; struct_lit_multiline_style: MultilineStyle, MultilineStyle::PreferSingle, false, "Multiline style on literal structs"; - fn_call_style: IndentStyle, IndentStyle::Block, false, "Indentation for function calls, etc."; + fn_call_indent: IndentStyle, IndentStyle::Block, false, "Indentation for function calls, etc."; report_todo: ReportTactic, ReportTactic::Never, false, "Report all, none or unnumbered occurrences of TODO in source file comments"; report_fixme: ReportTactic, ReportTactic::Never, false, diff --git a/src/expr.rs b/src/expr.rs index 9888ffc3e00..0bc09c7a390 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -2033,7 +2033,7 @@ where let used_width = extra_offset(callee_str, shape); let one_line_width = shape.width.checked_sub(used_width + 2 * paren_overhead)?; - let nested_shape = shape_from_fn_call_style( + let nested_shape = shape_from_fn_call_indent( context, shape, used_width + 2 * paren_overhead, @@ -2379,7 +2379,7 @@ pub fn can_be_overflowed_expr(context: &RewriteContext, expr: &ast::Expr, args_l match expr.node { ast::ExprKind::Match(..) => { (context.use_block_indent() && args_len == 1) - || (context.config.fn_call_style() == IndentStyle::Visual && args_len > 1) + || (context.config.fn_call_indent() == IndentStyle::Visual && args_len > 1) } ast::ExprKind::If(..) | ast::ExprKind::IfLet(..) | @@ -2391,7 +2391,7 @@ pub fn can_be_overflowed_expr(context: &RewriteContext, expr: &ast::Expr, args_l } ast::ExprKind::Block(..) | ast::ExprKind::Closure(..) => { context.use_block_indent() - || context.config.fn_call_style() == IndentStyle::Visual && args_len > 1 + || context.config.fn_call_indent() == IndentStyle::Visual && args_len > 1 } ast::ExprKind::Array(..) | ast::ExprKind::Call(..) | @@ -2722,7 +2722,7 @@ pub fn rewrite_field( } } -fn shape_from_fn_call_style( +fn shape_from_fn_call_indent( context: &RewriteContext, shape: Shape, overhead: usize, diff --git a/src/rewrite.rs b/src/rewrite.rs index e2be8ef086c..823f69dc6ff 100644 --- a/src/rewrite.rs +++ b/src/rewrite.rs @@ -43,7 +43,7 @@ impl<'a> RewriteContext<'a> { /// Return true if we should use block indent style for rewriting function call. pub fn use_block_indent(&self) -> bool { - self.config.fn_call_style() == IndentStyle::Block || self.use_block + self.config.fn_call_indent() == IndentStyle::Block || self.use_block } pub fn budget(&self, used_width: usize) -> usize { diff --git a/src/types.rs b/src/types.rs index e3f97cc6b70..fd41fedabb6 100644 --- a/src/types.rs +++ b/src/types.rs @@ -357,7 +357,7 @@ where }, separator_place: SeparatorPlace::Back, shape: list_shape, - ends_with_newline: tactic.ends_with_newline(context.config.fn_call_style()), + ends_with_newline: tactic.ends_with_newline(context.config.fn_call_indent()), preserve_newline: true, config: context.config, }; diff --git a/tests/source/big-impl-rfc.rs b/tests/source/big-impl-rfc.rs index 2b3928f431f..86812fd5379 100644 --- a/tests/source/big-impl-rfc.rs +++ b/tests/source/big-impl-rfc.rs @@ -1,5 +1,5 @@ // rustfmt-fn_args_indent: Block -// rustfmt-fn_call_style: Block +// rustfmt-fn_call_indent: Block // rustfmt-generics_indent: Block // rustfmt-where_style: Rfc diff --git a/tests/source/closure-block-inside-macro.rs b/tests/source/closure-block-inside-macro.rs index d567008c2ad..2f7e04957e9 100644 --- a/tests/source/closure-block-inside-macro.rs +++ b/tests/source/closure-block-inside-macro.rs @@ -1,4 +1,4 @@ -// rustfmt-fn_call_style: Block +// rustfmt-fn_call_indent: Block // #1547 fuzz_target!(|data: &[u8]| if let Some(first) = data.first() { diff --git a/tests/source/configs-fn_call_style-block-trailing-comma.rs b/tests/source/configs-fn_call_style-block-trailing-comma.rs index ad813f6b98a..9d948594d8b 100644 --- a/tests/source/configs-fn_call_style-block-trailing-comma.rs +++ b/tests/source/configs-fn_call_style-block-trailing-comma.rs @@ -1,5 +1,5 @@ // rustfmt-error_on_line_overflow: false -// rustfmt-fn_call_style: Block +// rustfmt-fn_call_indent: Block // rustfmt should not add trailing comma when rewriting macro. See #1528. fn a() { diff --git a/tests/source/configs-fn_call_style-block.rs b/tests/source/configs-fn_call_style-block.rs index ee6178c1902..76ccb001595 100644 --- a/tests/source/configs-fn_call_style-block.rs +++ b/tests/source/configs-fn_call_style-block.rs @@ -1,4 +1,4 @@ -// rustfmt-fn_call_style: Block +// rustfmt-fn_call_indent: Block // Function call style fn main() { diff --git a/tests/source/configs-fn_call_style-visual-trailing-comma.rs b/tests/source/configs-fn_call_style-visual-trailing-comma.rs index 61be7c5ea93..d6d1a86a631 100644 --- a/tests/source/configs-fn_call_style-visual-trailing-comma.rs +++ b/tests/source/configs-fn_call_style-visual-trailing-comma.rs @@ -1,5 +1,5 @@ // rustfmt-error_on_line_overflow: false -// rustfmt-fn_call_style: Visual +// rustfmt-fn_call_indent: Visual // rustfmt should not add trailing comma when rewriting macro. See #1528. fn a() { diff --git a/tests/source/configs-fn_call_style-visual.rs b/tests/source/configs-fn_call_style-visual.rs index 1cb48cfadd6..9561ffae23b 100644 --- a/tests/source/configs-fn_call_style-visual.rs +++ b/tests/source/configs-fn_call_style-visual.rs @@ -1,4 +1,4 @@ -// rustfmt-fn_call_style: Visual +// rustfmt-fn_call_indent: Visual // Function call style fn main() { diff --git a/tests/source/configs-fn_call_width-zero.rs b/tests/source/configs-fn_call_width-zero.rs index ee79c4ce805..da227dec4c7 100644 --- a/tests/source/configs-fn_call_width-zero.rs +++ b/tests/source/configs-fn_call_width-zero.rs @@ -1,5 +1,5 @@ // rustfmt-fn_call_width: 0 -// rustfmt-fn_call_style: block +// rustfmt-fn_call_indent: block // #1508 fn a() { diff --git a/tests/source/expr-block.rs b/tests/source/expr-block.rs index 2b899151535..3d46e3a9801 100644 --- a/tests/source/expr-block.rs +++ b/tests/source/expr-block.rs @@ -1,5 +1,5 @@ // rustfmt-array_indent: Block -// rustfmt-fn_call_style: Block +// rustfmt-fn_call_indent: Block // rustfmt-control_style: Rfc // Test expressions with block formatting. diff --git a/tests/target/big-impl-rfc.rs b/tests/target/big-impl-rfc.rs index 5ce1613d23b..b5c7b376f78 100644 --- a/tests/target/big-impl-rfc.rs +++ b/tests/target/big-impl-rfc.rs @@ -1,5 +1,5 @@ // rustfmt-fn_args_indent: Block -// rustfmt-fn_call_style: Block +// rustfmt-fn_call_indent: Block // rustfmt-generics_indent: Block // rustfmt-where_style: Rfc diff --git a/tests/target/closure-block-inside-macro.rs b/tests/target/closure-block-inside-macro.rs index d567008c2ad..2f7e04957e9 100644 --- a/tests/target/closure-block-inside-macro.rs +++ b/tests/target/closure-block-inside-macro.rs @@ -1,4 +1,4 @@ -// rustfmt-fn_call_style: Block +// rustfmt-fn_call_indent: Block // #1547 fuzz_target!(|data: &[u8]| if let Some(first) = data.first() { diff --git a/tests/target/configs-combine_control_expr-false.rs b/tests/target/configs-combine_control_expr-false.rs index 0d9ab24a6ed..432b2a03960 100644 --- a/tests/target/configs-combine_control_expr-false.rs +++ b/tests/target/configs-combine_control_expr-false.rs @@ -1,4 +1,4 @@ -// rustfmt-fn_call_style: Block +// rustfmt-fn_call_indent: Block // rustfmt-combine_control_expr: false // Combining openings and closings. See https://github.com/rust-lang-nursery/fmt-rfcs/issues/61. diff --git a/tests/target/configs-combine_control_expr-true.rs b/tests/target/configs-combine_control_expr-true.rs index 925d2233539..58db874a825 100644 --- a/tests/target/configs-combine_control_expr-true.rs +++ b/tests/target/configs-combine_control_expr-true.rs @@ -1,4 +1,4 @@ -// rustfmt-fn_call_style: Block +// rustfmt-fn_call_indent: Block // rustfmt-combine_control_expr: true // Combining openings and closings. See https://github.com/rust-lang-nursery/fmt-rfcs/issues/61. diff --git a/tests/target/configs-fn_call_style-block-tab_spaces-2.rs b/tests/target/configs-fn_call_style-block-tab_spaces-2.rs index 482c5c0e82a..238ab10060e 100644 --- a/tests/target/configs-fn_call_style-block-tab_spaces-2.rs +++ b/tests/target/configs-fn_call_style-block-tab_spaces-2.rs @@ -1,4 +1,4 @@ -// rustfmt-fn_call_style: Block +// rustfmt-fn_call_indent: Block // rustfmt-max_width: 80 // rustfmt-tab_spaces: 2 diff --git a/tests/target/configs-fn_call_style-block-trailing-comma.rs b/tests/target/configs-fn_call_style-block-trailing-comma.rs index 4405f89f2af..f54715aea55 100644 --- a/tests/target/configs-fn_call_style-block-trailing-comma.rs +++ b/tests/target/configs-fn_call_style-block-trailing-comma.rs @@ -1,5 +1,5 @@ // rustfmt-error_on_line_overflow: false -// rustfmt-fn_call_style: Block +// rustfmt-fn_call_indent: Block // rustfmt should not add trailing comma when rewriting macro. See #1528. fn a() { diff --git a/tests/target/configs-fn_call_style-block.rs b/tests/target/configs-fn_call_style-block.rs index 75d6b6765fb..0f9cbfcc0e3 100644 --- a/tests/target/configs-fn_call_style-block.rs +++ b/tests/target/configs-fn_call_style-block.rs @@ -1,4 +1,4 @@ -// rustfmt-fn_call_style: Block +// rustfmt-fn_call_indent: Block // Function call style fn main() { diff --git a/tests/target/configs-fn_call_style-visual-trailing-comma.rs b/tests/target/configs-fn_call_style-visual-trailing-comma.rs index 61be7c5ea93..d6d1a86a631 100644 --- a/tests/target/configs-fn_call_style-visual-trailing-comma.rs +++ b/tests/target/configs-fn_call_style-visual-trailing-comma.rs @@ -1,5 +1,5 @@ // rustfmt-error_on_line_overflow: false -// rustfmt-fn_call_style: Visual +// rustfmt-fn_call_indent: Visual // rustfmt should not add trailing comma when rewriting macro. See #1528. fn a() { diff --git a/tests/target/configs-fn_call_style-visual.rs b/tests/target/configs-fn_call_style-visual.rs index 598c2fff280..3a1e53a2274 100644 --- a/tests/target/configs-fn_call_style-visual.rs +++ b/tests/target/configs-fn_call_style-visual.rs @@ -1,4 +1,4 @@ -// rustfmt-fn_call_style: Visual +// rustfmt-fn_call_indent: Visual // Function call style fn main() { diff --git a/tests/target/configs-fn_call_width-zero.rs b/tests/target/configs-fn_call_width-zero.rs index 3193bc228f7..f91a03c8188 100644 --- a/tests/target/configs-fn_call_width-zero.rs +++ b/tests/target/configs-fn_call_width-zero.rs @@ -1,5 +1,5 @@ // rustfmt-fn_call_width: 0 -// rustfmt-fn_call_style: block +// rustfmt-fn_call_indent: block // #1508 fn a() { diff --git a/tests/target/expr-block.rs b/tests/target/expr-block.rs index 75d15418ba2..a76c761f1dc 100644 --- a/tests/target/expr-block.rs +++ b/tests/target/expr-block.rs @@ -1,5 +1,5 @@ // rustfmt-array_indent: Block -// rustfmt-fn_call_style: Block +// rustfmt-fn_call_indent: Block // rustfmt-control_style: Rfc // Test expressions with block formatting. From 40c5666af6bda89d3c8d5d12d01a53ed0afaf1e6 Mon Sep 17 00:00:00 2001 From: topecongiro Date: Sat, 4 Nov 2017 22:47:28 +0900 Subject: [PATCH 4/5] Rename 'struct_lit_style' to 'struct_lit_indent' --- Configurations.md | 10 +++++----- src/config.rs | 2 +- src/expr.rs | 4 ++-- src/lists.rs | 6 +++--- tests/config/small_tabs.toml | 2 +- tests/source/configs-struct_lit_style-block.rs | 2 +- tests/source/configs-struct_lit_style-visual.rs | 2 +- tests/source/struct_lits_visual.rs | 2 +- tests/source/struct_lits_visual_multiline.rs | 2 +- tests/source/struct_tuple_visual.rs | 2 +- tests/target/configs-struct_lit_style-block.rs | 2 +- tests/target/configs-struct_lit_style-visual.rs | 2 +- tests/target/struct_lits_visual.rs | 2 +- tests/target/struct_lits_visual_multiline.rs | 2 +- tests/target/struct_tuple_visual.rs | 2 +- 15 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Configurations.md b/Configurations.md index ae50daf7211..ee340f438ff 100644 --- a/Configurations.md +++ b/Configurations.md @@ -1868,9 +1868,9 @@ let lorem = Lorem { }; ``` -See also: [`struct_lit_style`](#struct_lit_style), [`struct_lit_width`](#struct_lit_width). +See also: [`struct_lit_indent`](#struct_lit_indent), [`struct_lit_width`](#struct_lit_width). -## `struct_lit_style` +## `struct_lit_indent` Style of struct definition @@ -1893,7 +1893,7 @@ let lorem = Lorem { ipsum: dolor, sit: amet, }; ``` -See also: [`struct_lit_multiline_style`](#struct_lit_multiline_style), [`struct_lit_style`](#struct_lit_style). +See also: [`struct_lit_multiline_style`](#struct_lit_multiline_style), [`struct_lit_indent`](#struct_lit_indent). ## `struct_lit_width` @@ -1910,9 +1910,9 @@ let lorem = Lorem { ipsum: dolor, sit: amet }; ``` #### Lines longer than `struct_lit_width`: -See [`struct_lit_style`](#struct_lit_style). +See [`struct_lit_indent`](#struct_lit_indent). -See also: [`struct_lit_multiline_style`](#struct_lit_multiline_style), [`struct_lit_style`](#struct_lit_style). +See also: [`struct_lit_multiline_style`](#struct_lit_multiline_style), [`struct_lit_indent`](#struct_lit_indent). ## `struct_variant_width` diff --git a/src/config.rs b/src/config.rs index a0d1dda2126..e9123ffc8cb 100644 --- a/src/config.rs +++ b/src/config.rs @@ -578,7 +578,7 @@ create_config! { where_pred_indent: IndentStyle, IndentStyle::Visual, false, "Indentation style of a where predicate"; generics_indent: IndentStyle, IndentStyle::Block, false, "Indentation of generics"; - struct_lit_style: IndentStyle, IndentStyle::Block, false, "Style of struct definition"; + struct_lit_indent: IndentStyle, IndentStyle::Block, false, "Style of struct definition"; struct_lit_multiline_style: MultilineStyle, MultilineStyle::PreferSingle, false, "Multiline style on literal structs"; fn_call_indent: IndentStyle, IndentStyle::Block, false, "Indentation for function calls, etc."; diff --git a/src/expr.rs b/src/expr.rs index 0bc09c7a390..a297b00a5f2 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -2640,7 +2640,7 @@ fn rewrite_struct_lit<'a>( let fields_str = wrap_struct_field(context, &fields_str, shape, v_shape, one_line_width); Some(format!("{} {{{}}}", path_str, fields_str)) - // FIXME if context.config.struct_lit_style() == Visual, but we run out + // FIXME if context.config.struct_lit_indent() == Visual, but we run out // of space, we should fall back to BlockIndent. } @@ -2651,7 +2651,7 @@ pub fn wrap_struct_field( nested_shape: Shape, one_line_width: usize, ) -> String { - if context.config.struct_lit_style() == IndentStyle::Block + if context.config.struct_lit_indent() == IndentStyle::Block && (fields_str.contains('\n') || context.config.struct_lit_multiline_style() == MultilineStyle::ForceMulti || fields_str.len() > one_line_width) diff --git a/src/lists.rs b/src/lists.rs index 73712033f6e..d560c88886c 100644 --- a/src/lists.rs +++ b/src/lists.rs @@ -737,7 +737,7 @@ pub fn struct_lit_shape( prefix_width: usize, suffix_width: usize, ) -> Option<(Option, Shape)> { - let v_shape = match context.config.struct_lit_style() { + let v_shape = match context.config.struct_lit_indent() { IndentStyle::Visual => shape .visual_indent(0) .shrink_left(prefix_width)? @@ -766,7 +766,7 @@ pub fn struct_lit_tactic( items: &[ListItem], ) -> DefinitiveListTactic { if let Some(h_shape) = h_shape { - let prelim_tactic = match (context.config.struct_lit_style(), items.len()) { + let prelim_tactic = match (context.config.struct_lit_indent(), items.len()) { (IndentStyle::Visual, 1) => ListTactic::HorizontalVertical, _ => context.config.struct_lit_multiline_style().to_list_tactic(), }; @@ -797,7 +797,7 @@ pub fn struct_lit_formatting<'a>( context: &'a RewriteContext, force_no_trailing_comma: bool, ) -> ListFormatting<'a> { - let ends_with_newline = context.config.struct_lit_style() != IndentStyle::Visual + let ends_with_newline = context.config.struct_lit_indent() != IndentStyle::Visual && tactic == DefinitiveListTactic::Vertical; ListFormatting { tactic: tactic, diff --git a/tests/config/small_tabs.toml b/tests/config/small_tabs.toml index f6a972c46b6..d48810bd578 100644 --- a/tests/config/small_tabs.toml +++ b/tests/config/small_tabs.toml @@ -12,7 +12,7 @@ where_layout = "Vertical" where_pred_indent = "Visual" generics_indent = "Visual" trailing_comma = "Vertical" -struct_lit_style = "Block" +struct_lit_indent = "Block" report_todo = "Always" report_fixme = "Never" reorder_imports = false diff --git a/tests/source/configs-struct_lit_style-block.rs b/tests/source/configs-struct_lit_style-block.rs index 69caa81ba09..4f66c192bbc 100644 --- a/tests/source/configs-struct_lit_style-block.rs +++ b/tests/source/configs-struct_lit_style-block.rs @@ -1,4 +1,4 @@ -// rustfmt-struct_lit_style: Block +// rustfmt-struct_lit_indent: Block // Struct literal-style fn main() { diff --git a/tests/source/configs-struct_lit_style-visual.rs b/tests/source/configs-struct_lit_style-visual.rs index 1e461b3d64a..837ae1b40cb 100644 --- a/tests/source/configs-struct_lit_style-visual.rs +++ b/tests/source/configs-struct_lit_style-visual.rs @@ -1,4 +1,4 @@ -// rustfmt-struct_lit_style: Visual +// rustfmt-struct_lit_indent: Visual // Struct literal-style fn main() { diff --git a/tests/source/struct_lits_visual.rs b/tests/source/struct_lits_visual.rs index 9156328dd0f..de083183ab9 100644 --- a/tests/source/struct_lits_visual.rs +++ b/tests/source/struct_lits_visual.rs @@ -1,6 +1,6 @@ // rustfmt-normalize_comments: true // rustfmt-wrap_comments: true -// rustfmt-struct_lit_style: Visual +// rustfmt-struct_lit_indent: Visual // rustfmt-error_on_line_overflow: false // Struct literal expressions. diff --git a/tests/source/struct_lits_visual_multiline.rs b/tests/source/struct_lits_visual_multiline.rs index 16c06934c28..e8af1486f36 100644 --- a/tests/source/struct_lits_visual_multiline.rs +++ b/tests/source/struct_lits_visual_multiline.rs @@ -1,6 +1,6 @@ // rustfmt-normalize_comments: true // rustfmt-wrap_comments: true -// rustfmt-struct_lit_style: Visual +// rustfmt-struct_lit_indent: Visual // rustfmt-struct_lit_multiline_style: ForceMulti // rustfmt-error_on_line_overflow: false diff --git a/tests/source/struct_tuple_visual.rs b/tests/source/struct_tuple_visual.rs index d7d9e961bc4..2bc2c11d333 100644 --- a/tests/source/struct_tuple_visual.rs +++ b/tests/source/struct_tuple_visual.rs @@ -1,7 +1,7 @@ // rustfmt-normalize_comments: true // rustfmt-wrap_comments: true // rustfmt-error_on_line_overflow: false -// rustfmt-struct_lit_style: Visual +// rustfmt-struct_lit_indent: Visual fn foo() { Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(f(), b()); diff --git a/tests/target/configs-struct_lit_style-block.rs b/tests/target/configs-struct_lit_style-block.rs index dc64fcfd159..19e276c2d76 100644 --- a/tests/target/configs-struct_lit_style-block.rs +++ b/tests/target/configs-struct_lit_style-block.rs @@ -1,4 +1,4 @@ -// rustfmt-struct_lit_style: Block +// rustfmt-struct_lit_indent: Block // Struct literal-style fn main() { diff --git a/tests/target/configs-struct_lit_style-visual.rs b/tests/target/configs-struct_lit_style-visual.rs index eb470e1e29c..fd20e2cde6c 100644 --- a/tests/target/configs-struct_lit_style-visual.rs +++ b/tests/target/configs-struct_lit_style-visual.rs @@ -1,4 +1,4 @@ -// rustfmt-struct_lit_style: Visual +// rustfmt-struct_lit_indent: Visual // Struct literal-style fn main() { diff --git a/tests/target/struct_lits_visual.rs b/tests/target/struct_lits_visual.rs index 7a0abb480e8..cef6e8b68c5 100644 --- a/tests/target/struct_lits_visual.rs +++ b/tests/target/struct_lits_visual.rs @@ -1,6 +1,6 @@ // rustfmt-normalize_comments: true // rustfmt-wrap_comments: true -// rustfmt-struct_lit_style: Visual +// rustfmt-struct_lit_indent: Visual // rustfmt-error_on_line_overflow: false // Struct literal expressions. diff --git a/tests/target/struct_lits_visual_multiline.rs b/tests/target/struct_lits_visual_multiline.rs index 02bbfa18784..74dd654ac50 100644 --- a/tests/target/struct_lits_visual_multiline.rs +++ b/tests/target/struct_lits_visual_multiline.rs @@ -1,6 +1,6 @@ // rustfmt-normalize_comments: true // rustfmt-wrap_comments: true -// rustfmt-struct_lit_style: Visual +// rustfmt-struct_lit_indent: Visual // rustfmt-struct_lit_multiline_style: ForceMulti // rustfmt-error_on_line_overflow: false diff --git a/tests/target/struct_tuple_visual.rs b/tests/target/struct_tuple_visual.rs index 02811668bcb..7723f042e6f 100644 --- a/tests/target/struct_tuple_visual.rs +++ b/tests/target/struct_tuple_visual.rs @@ -1,7 +1,7 @@ // rustfmt-normalize_comments: true // rustfmt-wrap_comments: true // rustfmt-error_on_line_overflow: false -// rustfmt-struct_lit_style: Visual +// rustfmt-struct_lit_indent: Visual fn foo() { Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(f(), b()); From 9cd5d88854227d009712e047d2388d7801b47e91 Mon Sep 17 00:00:00 2001 From: topecongiro Date: Sat, 4 Nov 2017 22:49:21 +0900 Subject: [PATCH 5/5] Rename test files --- ...onfigs-array_layout-block.rs => configs-array_indent-block.rs} | 0 ...figs-array_layout-visual.rs => configs-array_indent-visual.rs} | 0 ...gs-fn_args_layout-block.rs => configs-fn_args_indent-block.rs} | 0 ...-fn_args_layout-visual.rs => configs-fn_args_indent-visual.rs} | 0 ...ng-comma.rs => configs-fn_call_indent-block-trailing-comma.rs} | 0 ...igs-fn_call_style-block.rs => configs-fn_call_indent-block.rs} | 0 ...g-comma.rs => configs-fn_call_indent-visual-trailing-comma.rs} | 0 ...s-fn_call_style-visual.rs => configs-fn_call_indent-visual.rs} | 0 ...ruct_lit_style-block.rs => configs-struct_lit_indent-block.rs} | 0 ...ct_lit_style-visual.rs => configs-struct_lit_indent-visual.rs} | 0 tests/source/{fn_args_layout-block.rs => fn_args_indent-block.rs} | 0 ...onfigs-array_layout-block.rs => configs-array_indent-block.rs} | 0 ...figs-array_layout-visual.rs => configs-array_indent-visual.rs} | 0 ...gs-fn_args_layout-block.rs => configs-fn_args_indent-block.rs} | 0 ...-fn_args_layout-visual.rs => configs-fn_args_indent-visual.rs} | 0 ...b_spaces-2.rs => configs-fn_call_indent-block-tab_spaces-2.rs} | 0 ...ng-comma.rs => configs-fn_call_indent-block-trailing-comma.rs} | 0 ...igs-fn_call_style-block.rs => configs-fn_call_indent-block.rs} | 0 ...g-comma.rs => configs-fn_call_indent-visual-trailing-comma.rs} | 0 ...s-fn_call_style-visual.rs => configs-fn_call_indent-visual.rs} | 0 ...ruct_lit_style-block.rs => configs-struct_lit_indent-block.rs} | 0 ...ct_lit_style-visual.rs => configs-struct_lit_indent-visual.rs} | 0 tests/target/{fn_args_layout-block.rs => fn_args_indent-block.rs} | 0 23 files changed, 0 insertions(+), 0 deletions(-) rename tests/source/{configs-array_layout-block.rs => configs-array_indent-block.rs} (100%) rename tests/source/{configs-array_layout-visual.rs => configs-array_indent-visual.rs} (100%) rename tests/source/{configs-fn_args_layout-block.rs => configs-fn_args_indent-block.rs} (100%) rename tests/source/{configs-fn_args_layout-visual.rs => configs-fn_args_indent-visual.rs} (100%) rename tests/source/{configs-fn_call_style-block-trailing-comma.rs => configs-fn_call_indent-block-trailing-comma.rs} (100%) rename tests/source/{configs-fn_call_style-block.rs => configs-fn_call_indent-block.rs} (100%) rename tests/source/{configs-fn_call_style-visual-trailing-comma.rs => configs-fn_call_indent-visual-trailing-comma.rs} (100%) rename tests/source/{configs-fn_call_style-visual.rs => configs-fn_call_indent-visual.rs} (100%) rename tests/source/{configs-struct_lit_style-block.rs => configs-struct_lit_indent-block.rs} (100%) rename tests/source/{configs-struct_lit_style-visual.rs => configs-struct_lit_indent-visual.rs} (100%) rename tests/source/{fn_args_layout-block.rs => fn_args_indent-block.rs} (100%) rename tests/target/{configs-array_layout-block.rs => configs-array_indent-block.rs} (100%) rename tests/target/{configs-array_layout-visual.rs => configs-array_indent-visual.rs} (100%) rename tests/target/{configs-fn_args_layout-block.rs => configs-fn_args_indent-block.rs} (100%) rename tests/target/{configs-fn_args_layout-visual.rs => configs-fn_args_indent-visual.rs} (100%) rename tests/target/{configs-fn_call_style-block-tab_spaces-2.rs => configs-fn_call_indent-block-tab_spaces-2.rs} (100%) rename tests/target/{configs-fn_call_style-block-trailing-comma.rs => configs-fn_call_indent-block-trailing-comma.rs} (100%) rename tests/target/{configs-fn_call_style-block.rs => configs-fn_call_indent-block.rs} (100%) rename tests/target/{configs-fn_call_style-visual-trailing-comma.rs => configs-fn_call_indent-visual-trailing-comma.rs} (100%) rename tests/target/{configs-fn_call_style-visual.rs => configs-fn_call_indent-visual.rs} (100%) rename tests/target/{configs-struct_lit_style-block.rs => configs-struct_lit_indent-block.rs} (100%) rename tests/target/{configs-struct_lit_style-visual.rs => configs-struct_lit_indent-visual.rs} (100%) rename tests/target/{fn_args_layout-block.rs => fn_args_indent-block.rs} (100%) diff --git a/tests/source/configs-array_layout-block.rs b/tests/source/configs-array_indent-block.rs similarity index 100% rename from tests/source/configs-array_layout-block.rs rename to tests/source/configs-array_indent-block.rs diff --git a/tests/source/configs-array_layout-visual.rs b/tests/source/configs-array_indent-visual.rs similarity index 100% rename from tests/source/configs-array_layout-visual.rs rename to tests/source/configs-array_indent-visual.rs diff --git a/tests/source/configs-fn_args_layout-block.rs b/tests/source/configs-fn_args_indent-block.rs similarity index 100% rename from tests/source/configs-fn_args_layout-block.rs rename to tests/source/configs-fn_args_indent-block.rs diff --git a/tests/source/configs-fn_args_layout-visual.rs b/tests/source/configs-fn_args_indent-visual.rs similarity index 100% rename from tests/source/configs-fn_args_layout-visual.rs rename to tests/source/configs-fn_args_indent-visual.rs diff --git a/tests/source/configs-fn_call_style-block-trailing-comma.rs b/tests/source/configs-fn_call_indent-block-trailing-comma.rs similarity index 100% rename from tests/source/configs-fn_call_style-block-trailing-comma.rs rename to tests/source/configs-fn_call_indent-block-trailing-comma.rs diff --git a/tests/source/configs-fn_call_style-block.rs b/tests/source/configs-fn_call_indent-block.rs similarity index 100% rename from tests/source/configs-fn_call_style-block.rs rename to tests/source/configs-fn_call_indent-block.rs diff --git a/tests/source/configs-fn_call_style-visual-trailing-comma.rs b/tests/source/configs-fn_call_indent-visual-trailing-comma.rs similarity index 100% rename from tests/source/configs-fn_call_style-visual-trailing-comma.rs rename to tests/source/configs-fn_call_indent-visual-trailing-comma.rs diff --git a/tests/source/configs-fn_call_style-visual.rs b/tests/source/configs-fn_call_indent-visual.rs similarity index 100% rename from tests/source/configs-fn_call_style-visual.rs rename to tests/source/configs-fn_call_indent-visual.rs diff --git a/tests/source/configs-struct_lit_style-block.rs b/tests/source/configs-struct_lit_indent-block.rs similarity index 100% rename from tests/source/configs-struct_lit_style-block.rs rename to tests/source/configs-struct_lit_indent-block.rs diff --git a/tests/source/configs-struct_lit_style-visual.rs b/tests/source/configs-struct_lit_indent-visual.rs similarity index 100% rename from tests/source/configs-struct_lit_style-visual.rs rename to tests/source/configs-struct_lit_indent-visual.rs diff --git a/tests/source/fn_args_layout-block.rs b/tests/source/fn_args_indent-block.rs similarity index 100% rename from tests/source/fn_args_layout-block.rs rename to tests/source/fn_args_indent-block.rs diff --git a/tests/target/configs-array_layout-block.rs b/tests/target/configs-array_indent-block.rs similarity index 100% rename from tests/target/configs-array_layout-block.rs rename to tests/target/configs-array_indent-block.rs diff --git a/tests/target/configs-array_layout-visual.rs b/tests/target/configs-array_indent-visual.rs similarity index 100% rename from tests/target/configs-array_layout-visual.rs rename to tests/target/configs-array_indent-visual.rs diff --git a/tests/target/configs-fn_args_layout-block.rs b/tests/target/configs-fn_args_indent-block.rs similarity index 100% rename from tests/target/configs-fn_args_layout-block.rs rename to tests/target/configs-fn_args_indent-block.rs diff --git a/tests/target/configs-fn_args_layout-visual.rs b/tests/target/configs-fn_args_indent-visual.rs similarity index 100% rename from tests/target/configs-fn_args_layout-visual.rs rename to tests/target/configs-fn_args_indent-visual.rs diff --git a/tests/target/configs-fn_call_style-block-tab_spaces-2.rs b/tests/target/configs-fn_call_indent-block-tab_spaces-2.rs similarity index 100% rename from tests/target/configs-fn_call_style-block-tab_spaces-2.rs rename to tests/target/configs-fn_call_indent-block-tab_spaces-2.rs diff --git a/tests/target/configs-fn_call_style-block-trailing-comma.rs b/tests/target/configs-fn_call_indent-block-trailing-comma.rs similarity index 100% rename from tests/target/configs-fn_call_style-block-trailing-comma.rs rename to tests/target/configs-fn_call_indent-block-trailing-comma.rs diff --git a/tests/target/configs-fn_call_style-block.rs b/tests/target/configs-fn_call_indent-block.rs similarity index 100% rename from tests/target/configs-fn_call_style-block.rs rename to tests/target/configs-fn_call_indent-block.rs diff --git a/tests/target/configs-fn_call_style-visual-trailing-comma.rs b/tests/target/configs-fn_call_indent-visual-trailing-comma.rs similarity index 100% rename from tests/target/configs-fn_call_style-visual-trailing-comma.rs rename to tests/target/configs-fn_call_indent-visual-trailing-comma.rs diff --git a/tests/target/configs-fn_call_style-visual.rs b/tests/target/configs-fn_call_indent-visual.rs similarity index 100% rename from tests/target/configs-fn_call_style-visual.rs rename to tests/target/configs-fn_call_indent-visual.rs diff --git a/tests/target/configs-struct_lit_style-block.rs b/tests/target/configs-struct_lit_indent-block.rs similarity index 100% rename from tests/target/configs-struct_lit_style-block.rs rename to tests/target/configs-struct_lit_indent-block.rs diff --git a/tests/target/configs-struct_lit_style-visual.rs b/tests/target/configs-struct_lit_indent-visual.rs similarity index 100% rename from tests/target/configs-struct_lit_style-visual.rs rename to tests/target/configs-struct_lit_indent-visual.rs diff --git a/tests/target/fn_args_layout-block.rs b/tests/target/fn_args_indent-block.rs similarity index 100% rename from tests/target/fn_args_layout-block.rs rename to tests/target/fn_args_indent-block.rs