]> git.lizzy.rs Git - rust.git/commitdiff
Enable overflow_delimited_expr for structs
authorChristian Duerr <contact@christianduerr.com>
Sat, 30 Mar 2019 17:37:37 +0000 (18:37 +0100)
committerChristian Duerr <contact@christianduerr.com>
Sat, 30 Mar 2019 17:37:37 +0000 (18:37 +0100)
This fixes https://github.com/rust-lang/rustfmt/issues/3482.

src/expr.rs
tests/source/match_overflow_expr.rs [new file with mode: 0644]
tests/target/match_overflow_expr.rs [new file with mode: 0644]

index 8d241dff1f9690edb24183e35c7c53290f9711f1..f383eaca36fea99b64f0b59b4103eac94b40ef30 100644 (file)
@@ -1346,6 +1346,7 @@ pub fn can_be_overflowed_expr(
         ast::ExprKind::Match(..) => {
             (context.use_block_indent() && args_len == 1)
                 || (context.config.indent_style() == IndentStyle::Visual && args_len > 1)
+                || context.config.overflow_delimited_expr()
         }
         ast::ExprKind::If(..)
         | ast::ExprKind::IfLet(..)
diff --git a/tests/source/match_overflow_expr.rs b/tests/source/match_overflow_expr.rs
new file mode 100644 (file)
index 0000000..91275a8
--- /dev/null
@@ -0,0 +1,53 @@
+// rustfmt-overflow_delimited_expr: true
+
+fn main() {
+    println!(
+        "Foobar: {}",
+        match "input" {
+            "a" => "",
+            "b" => "",
+            "c" => "",
+            "d" => "",
+            "e" => "",
+            "f" => "",
+            "g" => "",
+            "h" => "",
+            "i" => "",
+            "j" => "",
+            "k" => "",
+            "l" => "",
+            "m" => "",
+            "n" => "",
+            "o" => "",
+            "p" => "",
+            "q" => "",
+            "r" => "Rust",
+        }
+    );
+}
+
+fn main() {
+    println!(
+        "Very Long Input String Which Makes It Impossible To Fit On The Same Line: {}",
+        match "input" {
+            "a" => "",
+            "b" => "",
+            "c" => "",
+            "d" => "",
+            "e" => "",
+            "f" => "",
+            "g" => "",
+            "h" => "",
+            "i" => "",
+            "j" => "",
+            "k" => "",
+            "l" => "",
+            "m" => "",
+            "n" => "",
+            "o" => "",
+            "p" => "",
+            "q" => "",
+            "r" => "Rust",
+        }
+    );
+}
diff --git a/tests/target/match_overflow_expr.rs b/tests/target/match_overflow_expr.rs
new file mode 100644 (file)
index 0000000..b817879
--- /dev/null
@@ -0,0 +1,50 @@
+// rustfmt-overflow_delimited_expr: true
+
+fn main() {
+    println!("Foobar: {}", match "input" {
+        "a" => "",
+        "b" => "",
+        "c" => "",
+        "d" => "",
+        "e" => "",
+        "f" => "",
+        "g" => "",
+        "h" => "",
+        "i" => "",
+        "j" => "",
+        "k" => "",
+        "l" => "",
+        "m" => "",
+        "n" => "",
+        "o" => "",
+        "p" => "",
+        "q" => "",
+        "r" => "Rust",
+    });
+}
+
+fn main() {
+    println!(
+        "Very Long Input String Which Makes It Impossible To Fit On The Same Line: {}",
+        match "input" {
+            "a" => "",
+            "b" => "",
+            "c" => "",
+            "d" => "",
+            "e" => "",
+            "f" => "",
+            "g" => "",
+            "h" => "",
+            "i" => "",
+            "j" => "",
+            "k" => "",
+            "l" => "",
+            "m" => "",
+            "n" => "",
+            "o" => "",
+            "p" => "",
+            "q" => "",
+            "r" => "Rust",
+        }
+    );
+}