about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorOtavio Salvador <otavio@ossystems.com.br>2018-10-13 09:05:54 -0300
committerOtavio Salvador <otavio@ossystems.com.br>2018-10-13 14:12:43 -0300
commitef59b34cd7011302008230d928e5379d0e855edc (patch)
tree0ab5962160f21be6f2894c14790f698a3fda8e0e /src
parent8feeddf1f88cb3753b51c894cffea4f11b0036d3 (diff)
Avoid control flow expressions conditions to go multi line
Extends the multi line condition to over other control flow
expressions, it now covers: `if`, `if let`, `for`, `loop`, `while`,
`while let` and `match`.

Refs: #3029

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
Diffstat (limited to 'src')
-rw-r--r--src/overflow.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/overflow.rs b/src/overflow.rs
index 40cfc4be30f..fc1803b2ab6 100644
--- a/src/overflow.rs
+++ b/src/overflow.rs
@@ -404,7 +404,15 @@ impl<'a> Context<'a> {
                             closures::rewrite_last_closure(self.context, expr, shape)
                         }
                     }
-                    ast::ExprKind::Match(..) => {
+                    // When overflowing the expressions which consists of a control flow
+                    // expression, avoid condition to use multi line.
+                    ast::ExprKind::If(..)
+                    | ast::ExprKind::IfLet(..)
+                    | ast::ExprKind::ForLoop(..)
+                    | ast::ExprKind::Loop(..)
+                    | ast::ExprKind::While(..)
+                    | ast::ExprKind::WhileLet(..)
+                    | ast::ExprKind::Match(..) => {
                         let multi_line = rewrite_cond(self.context, expr, shape)
                             .map_or(false, |cond| cond.contains('\n'));