]> git.lizzy.rs Git - rust.git/commitdiff
Rename wrap_match_arms to match_arm_blocks
authorNick Cameron <ncameron@mozilla.com>
Mon, 27 Nov 2017 04:35:27 +0000 (17:35 +1300)
committerNick Cameron <ncameron@mozilla.com>
Mon, 27 Nov 2017 04:35:27 +0000 (17:35 +1300)
18 files changed:
Configurations.md
src/config.rs
src/expr.rs
tests/source/configs-match_arm_blocks-false.rs [new file with mode: 0644]
tests/source/configs-match_arm_blocks-true.rs [new file with mode: 0644]
tests/source/configs-wrap_match_arms-false.rs [deleted file]
tests/source/configs-wrap_match_arms-true.rs [deleted file]
tests/source/issue-1127.rs
tests/source/match-nowrap-trailing-comma.rs
tests/source/match-nowrap.rs
tests/target/configs-control_style-rfc.rs
tests/target/configs-match_arm_blocks-false.rs [new file with mode: 0644]
tests/target/configs-match_arm_blocks-true.rs [new file with mode: 0644]
tests/target/configs-wrap_match_arms-false.rs [deleted file]
tests/target/configs-wrap_match_arms-true.rs [deleted file]
tests/target/issue-1127.rs
tests/target/match-nowrap-trailing-comma.rs
tests/target/match-nowrap.rs

index 76589314e03c3d56a34af599688b8be63204b1b6..50a0c4a1c898d57b96ff477beac8a38115fe92b3 100644 (file)
@@ -1138,7 +1138,7 @@ match lorem {
 }
 ```
 
-See also: [`trailing_comma`](#trailing_comma), [`wrap_match_arms`](#wrap_match_arms).
+See also: [`trailing_comma`](#trailing_comma), [`match_arm_blocks`](#match_arm_blocks).
 
 ## `max_width`
 
@@ -1806,7 +1806,7 @@ Break comments to fit on the line
 // commodo consequat.
 ```
 
-## `wrap_match_arms`
+## `match_arm_blocks`
 
 Wrap the body of arms in blocks when it does not fit on the same line with the pattern of arms
 
index c622522223102f277c7aa0fc8f71795467f6adc3..f1ce217a36b186cec0abd2cd08873f727c6106f3 100644 (file)
@@ -618,12 +618,6 @@ pub fn get_toml_path(dir: &Path) -> Result<Option<PathBuf>, Error> {
     reorder_imported_names: bool, true, false,
         "Reorder lists of names in import statements alphabetically";
 
-    // Match
-    wrap_match_arms: bool, true, false, "Wrap the body of arms in blocks when it does not fit on \
-                                  the same line with the pattern of arms";
-    match_block_trailing_comma: bool, false, false,
-        "Put a trailing comma after a block based match arm (non-block arms are not affected)";
-
     // Spaces around punctuation
     binop_separator: SeparatorPlace, SeparatorPlace::Front, false,
         "Where to put a binary operator when a binary expression goes multiline.";
@@ -643,6 +637,8 @@ pub fn get_toml_path(dir: &Path) -> Result<Option<PathBuf>, Error> {
         "Remove blank lines at start or end of a block";
     same_line_attributes: bool, true, false,
         "Try to put attributes on the same line as fields and variants.";
+    match_arm_blocks: bool, true, false, "Wrap the body of arms in blocks when it does not fit on \
+        the same line with the pattern of arms";
     force_multiline_blocks: bool, false, false,
         "Force multiline closure bodies and match arms to be wrapped in a block";
     fn_args_density: Density, Density::Tall, false, "Argument density in functions";
@@ -653,6 +649,8 @@ pub fn get_toml_path(dir: &Path) -> Result<Option<PathBuf>, Error> {
         "How to handle trailing commas for lists";
     trailing_semicolon: bool, true, false,
         "Add trailing semicolon after break, continue and return";
+    match_block_trailing_comma: bool, false, false,
+        "Put a trailing comma after a block based match arm (non-block arms are not affected)";
 
     // Options that can change the source code beyond whitespace/blocks (somewhat linty things)
     merge_derives: bool, true, true, "Merge multiple `#[derive(...)]` into a single one";
index 9d29425a5ddc7fd914dab963b9a51c88b1dfa947..812ebd5cf3a264e634aea12c86391e23507be3c3 100644 (file)
@@ -1559,7 +1559,7 @@ fn rewrite_match_body(
 
         let indent_str = shape.indent.to_string(context.config);
         let nested_indent_str = next_line_indent.to_string(context.config);
-        let (body_prefix, body_suffix) = if context.config.wrap_match_arms() {
+        let (body_prefix, body_suffix) = if context.config.match_arm_blocks() {
             let comma = if context.config.match_block_trailing_comma() {
                 ","
             } else {
diff --git a/tests/source/configs-match_arm_blocks-false.rs b/tests/source/configs-match_arm_blocks-false.rs
new file mode 100644 (file)
index 0000000..53e37e1
--- /dev/null
@@ -0,0 +1,11 @@
+// rustfmt-match_arm_blocks: false
+// Wrap match-arms
+
+fn main() {
+    match lorem {
+        true => foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x),
+        false => {
+            println!("{}", sit)
+        }
+    }
+}
diff --git a/tests/source/configs-match_arm_blocks-true.rs b/tests/source/configs-match_arm_blocks-true.rs
new file mode 100644 (file)
index 0000000..a452b13
--- /dev/null
@@ -0,0 +1,11 @@
+// rustfmt-match_arm_blocks: true
+// Wrap match-arms
+
+fn main() {
+    match lorem {
+        true => foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x),
+        false => {
+            println!("{}", sit)
+        }
+    }
+}
diff --git a/tests/source/configs-wrap_match_arms-false.rs b/tests/source/configs-wrap_match_arms-false.rs
deleted file mode 100644 (file)
index d1c05c2..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-// rustfmt-wrap_match_arms: false
-// Wrap match-arms
-
-fn main() {
-    match lorem {
-        true => foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x),
-        false => {
-            println!("{}", sit)
-        }
-    }
-}
diff --git a/tests/source/configs-wrap_match_arms-true.rs b/tests/source/configs-wrap_match_arms-true.rs
deleted file mode 100644 (file)
index 8ddc5eb..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-// rustfmt-wrap_match_arms: true
-// Wrap match-arms
-
-fn main() {
-    match lorem {
-        true => foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x),
-        false => {
-            println!("{}", sit)
-        }
-    }
-}
index 4820f5ea2295d84bdd2803c2989efe05036d6ea7..9996c194818796b74575018e80ab99373b9238ea 100644 (file)
@@ -1,5 +1,5 @@
 // rustfmt-max_width:120
-// rustfmt-wrap_match_arms: false
+// rustfmt-match_arm_blocks: false
 // rustfmt-match_block_trailing_comma: true
 
 fn a_very_very_very_very_very_very_very_very_very_very_very_long_function_name() -> i32 {
index f6e88406bb46218021697a58f52890032e9cf6ec..134d2fdf9a4a5bc1f1602936dee01335bb1f7164 100644 (file)
@@ -1,4 +1,4 @@
-// rustfmt-wrap_match_arms: false
+// rustfmt-match_arm_blocks: false
 // rustfmt-match_block_trailing_comma: true
 // Match expressions, no unwrapping of block arms or wrapping of multiline
 // expressions.
index 83e0fbbd4509b9b8442bed66e901faa0f6218b6c..db22cd9f010662002cfc5bf31f1f9663aa23d6ed 100644 (file)
@@ -1,4 +1,4 @@
-// rustfmt-wrap_match_arms: false
+// rustfmt-match_arm_blocks: false
 // Match expressions, no unwrapping of block arms or wrapping of multiline
 // expressions.
 
index 5e19681f90bbbceb909270bbdc917dcef4e08c02..6619d8b2630369ac8b6c325f821340116548bb7c 100644 (file)
@@ -26,7 +26,7 @@ fn issue1656() {
             match rewrite {
                 Some(ref body_str)
                     if (!body_str.contains('\n') && body_str.len() <= arm_shape.width)
-                        || !context.config.wrap_match_arms()
+                        || !context.config.match_arm_blocks()
                         || (extend && first_line_width(body_str) <= arm_shape.width)
                         || is_block =>
                 {
diff --git a/tests/target/configs-match_arm_blocks-false.rs b/tests/target/configs-match_arm_blocks-false.rs
new file mode 100644 (file)
index 0000000..4d53a96
--- /dev/null
@@ -0,0 +1,10 @@
+// rustfmt-match_arm_blocks: false
+// Wrap match-arms
+
+fn main() {
+    match lorem {
+        true =>
+            foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x),
+        false => println!("{}", sit),
+    }
+}
diff --git a/tests/target/configs-match_arm_blocks-true.rs b/tests/target/configs-match_arm_blocks-true.rs
new file mode 100644 (file)
index 0000000..d75ef03
--- /dev/null
@@ -0,0 +1,11 @@
+// rustfmt-match_arm_blocks: true
+// Wrap match-arms
+
+fn main() {
+    match lorem {
+        true => {
+            foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x)
+        }
+        false => println!("{}", sit),
+    }
+}
diff --git a/tests/target/configs-wrap_match_arms-false.rs b/tests/target/configs-wrap_match_arms-false.rs
deleted file mode 100644 (file)
index e4ca37b..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-// rustfmt-wrap_match_arms: false
-// Wrap match-arms
-
-fn main() {
-    match lorem {
-        true =>
-            foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x),
-        false => println!("{}", sit),
-    }
-}
diff --git a/tests/target/configs-wrap_match_arms-true.rs b/tests/target/configs-wrap_match_arms-true.rs
deleted file mode 100644 (file)
index f6307e5..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-// rustfmt-wrap_match_arms: true
-// Wrap match-arms
-
-fn main() {
-    match lorem {
-        true => {
-            foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x)
-        }
-        false => println!("{}", sit),
-    }
-}
index afc79767cb794dd481064387250c4d64b678a48e..dbdd234b8e4bee96c4062e28f2f6af5e470bc551 100644 (file)
@@ -1,5 +1,5 @@
 // rustfmt-max_width:120
-// rustfmt-wrap_match_arms: false
+// rustfmt-match_arm_blocks: false
 // rustfmt-match_block_trailing_comma: true
 
 fn a_very_very_very_very_very_very_very_very_very_very_very_long_function_name() -> i32 {
index 0abc358a3405d541d3eb9c11d5ab7ac7bdaba0e4..19ef2144822a692727382dc9e49f7702f1aac26b 100644 (file)
@@ -1,4 +1,4 @@
-// rustfmt-wrap_match_arms: false
+// rustfmt-match_arm_blocks: false
 // rustfmt-match_block_trailing_comma: true
 // Match expressions, no unwrapping of block arms or wrapping of multiline
 // expressions.
index 1457109821880441e2c3ee1a747dbd4da0d9a0e8..9e674b1e2f5403eebb6273bab8bfb1d1cb9e61f1 100644 (file)
@@ -1,4 +1,4 @@
-// rustfmt-wrap_match_arms: false
+// rustfmt-match_arm_blocks: false
 // Match expressions, no unwrapping of block arms or wrapping of multiline
 // expressions.