]> git.lizzy.rs Git - rust.git/commitdiff
Prefer to put the whole pattern of match arm on one line
authorSeiichi Uchida <seuchida@gmail.com>
Sun, 9 Jul 2017 17:18:53 +0000 (02:18 +0900)
committerSeiichi Uchida <seuchida@gmail.com>
Sun, 9 Jul 2017 17:20:28 +0000 (02:20 +0900)
src/expr.rs

index 4b4596e59d7f8dc6781bd18eb03e63ae55a63dfe..b304af8e5cdf1d22e1ae6192c937c9bead57b846 100644 (file)
@@ -1687,14 +1687,14 @@ fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
                 .collect::<Option<Vec<_>>>()
         );
 
-        let all_simple = pat_strs.iter().all(|p| pat_is_simple(p));
+        let all_simple = pat_strs.iter().all(|p| !p.contains('\n'));
         let items: Vec<_> = pat_strs.into_iter().map(ListItem::from_str).collect();
+        let mut tactic = definitive_tactic(&items, ListTactic::HorizontalVertical, pat_shape.width);
+        if tactic == DefinitiveListTactic::Horizontal && all_simple {
+            tactic = DefinitiveListTactic::Mixed;
+        }
         let fmt = ListFormatting {
-            tactic: if all_simple {
-                DefinitiveListTactic::Mixed
-            } else {
-                DefinitiveListTactic::Vertical
-            },
+            tactic: tactic,
             separator: " |",
             trailing_separator: SeparatorTactic::Never,
             shape: pat_shape,