Skip to content

Commit 9a33255

Browse files
committed
Rename wrap_match_arms to match_arm_blocks
1 parent 8f4d85a commit 9a33255

14 files changed

+18
-20
lines changed

Configurations.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,7 +1138,7 @@ match lorem {
11381138
}
11391139
```
11401140

1141-
See also: [`trailing_comma`](#trailing_comma), [`wrap_match_arms`](#wrap_match_arms).
1141+
See also: [`trailing_comma`](#trailing_comma), [`match_arm_blocks`](#match_arm_blocks).
11421142

11431143
## `max_width`
11441144

@@ -1806,7 +1806,7 @@ Break comments to fit on the line
18061806
// commodo consequat.
18071807
```
18081808

1809-
## `wrap_match_arms`
1809+
## `match_arm_blocks`
18101810

18111811
Wrap the body of arms in blocks when it does not fit on the same line with the pattern of arms
18121812

src/config.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -618,12 +618,6 @@ create_config! {
618618
reorder_imported_names: bool, true, false,
619619
"Reorder lists of names in import statements alphabetically";
620620

621-
// Match
622-
wrap_match_arms: bool, true, false, "Wrap the body of arms in blocks when it does not fit on \
623-
the same line with the pattern of arms";
624-
match_block_trailing_comma: bool, false, false,
625-
"Put a trailing comma after a block based match arm (non-block arms are not affected)";
626-
627621
// Spaces around punctuation
628622
binop_separator: SeparatorPlace, SeparatorPlace::Front, false,
629623
"Where to put a binary operator when a binary expression goes multiline.";
@@ -643,6 +637,8 @@ create_config! {
643637
"Remove blank lines at start or end of a block";
644638
same_line_attributes: bool, true, false,
645639
"Try to put attributes on the same line as fields and variants.";
640+
match_arm_blocks: bool, true, false, "Wrap the body of arms in blocks when it does not fit on \
641+
the same line with the pattern of arms";
646642
force_multiline_blocks: bool, false, false,
647643
"Force multiline closure bodies and match arms to be wrapped in a block";
648644
fn_args_density: Density, Density::Tall, false, "Argument density in functions";
@@ -653,6 +649,8 @@ create_config! {
653649
"How to handle trailing commas for lists";
654650
trailing_semicolon: bool, true, false,
655651
"Add trailing semicolon after break, continue and return";
652+
match_block_trailing_comma: bool, false, false,
653+
"Put a trailing comma after a block based match arm (non-block arms are not affected)";
656654

657655
// Options that can change the source code beyond whitespace/blocks (somewhat linty things)
658656
merge_derives: bool, true, true, "Merge multiple `#[derive(...)]` into a single one";

src/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1559,7 +1559,7 @@ fn rewrite_match_body(
15591559

15601560
let indent_str = shape.indent.to_string(context.config);
15611561
let nested_indent_str = next_line_indent.to_string(context.config);
1562-
let (body_prefix, body_suffix) = if context.config.wrap_match_arms() {
1562+
let (body_prefix, body_suffix) = if context.config.match_arm_blocks() {
15631563
let comma = if context.config.match_block_trailing_comma() {
15641564
","
15651565
} else {

tests/source/configs-wrap_match_arms-true.rs renamed to tests/source/configs-match_arm_blocks-false.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// rustfmt-wrap_match_arms: true
1+
// rustfmt-match_arm_blocks: false
22
// Wrap match-arms
33

44
fn main() {

tests/source/configs-wrap_match_arms-false.rs renamed to tests/source/configs-match_arm_blocks-true.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// rustfmt-wrap_match_arms: false
1+
// rustfmt-match_arm_blocks: true
22
// Wrap match-arms
33

44
fn main() {

tests/source/issue-1127.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// rustfmt-max_width:120
2-
// rustfmt-wrap_match_arms: false
2+
// rustfmt-match_arm_blocks: false
33
// rustfmt-match_block_trailing_comma: true
44

55
fn a_very_very_very_very_very_very_very_very_very_very_very_long_function_name() -> i32 {

tests/source/match-nowrap-trailing-comma.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// rustfmt-wrap_match_arms: false
1+
// rustfmt-match_arm_blocks: false
22
// rustfmt-match_block_trailing_comma: true
33
// Match expressions, no unwrapping of block arms or wrapping of multiline
44
// expressions.

tests/source/match-nowrap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// rustfmt-wrap_match_arms: false
1+
// rustfmt-match_arm_blocks: false
22
// Match expressions, no unwrapping of block arms or wrapping of multiline
33
// expressions.
44

tests/target/configs-control_style-rfc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ fn issue1656() {
2626
match rewrite {
2727
Some(ref body_str)
2828
if (!body_str.contains('\n') && body_str.len() <= arm_shape.width)
29-
|| !context.config.wrap_match_arms()
29+
|| !context.config.match_arm_blocks()
3030
|| (extend && first_line_width(body_str) <= arm_shape.width)
3131
|| is_block =>
3232
{

tests/target/configs-wrap_match_arms-false.rs renamed to tests/target/configs-match_arm_blocks-false.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// rustfmt-wrap_match_arms: false
1+
// rustfmt-match_arm_blocks: false
22
// Wrap match-arms
33

44
fn main() {

tests/target/configs-wrap_match_arms-true.rs renamed to tests/target/configs-match_arm_blocks-true.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// rustfmt-wrap_match_arms: true
1+
// rustfmt-match_arm_blocks: true
22
// Wrap match-arms
33

44
fn main() {

tests/target/issue-1127.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// rustfmt-max_width:120
2-
// rustfmt-wrap_match_arms: false
2+
// rustfmt-match_arm_blocks: false
33
// rustfmt-match_block_trailing_comma: true
44

55
fn a_very_very_very_very_very_very_very_very_very_very_very_long_function_name() -> i32 {

tests/target/match-nowrap-trailing-comma.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// rustfmt-wrap_match_arms: false
1+
// rustfmt-match_arm_blocks: false
22
// rustfmt-match_block_trailing_comma: true
33
// Match expressions, no unwrapping of block arms or wrapping of multiline
44
// expressions.

tests/target/match-nowrap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// rustfmt-wrap_match_arms: false
1+
// rustfmt-match_arm_blocks: false
22
// Match expressions, no unwrapping of block arms or wrapping of multiline
33
// expressions.
44

0 commit comments

Comments
 (0)