diff options
| author | Seiichi Uchida <seuchida@gmail.com> | 2018-10-13 10:36:31 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-10-13 10:36:31 +0900 |
| commit | a0d1f171dc1db055e15f42e40bb5d3f73837eaee (patch) | |
| tree | d64d2be9d494dac65e6bfd029de6b8a86728ddd5 /src | |
| parent | 8b709c0019244d8554c0799084815146a5ce800a (diff) | |
| parent | 8feeddf1f88cb3753b51c894cffea4f11b0036d3 (diff) | |
Merge pull request #3090 from otavio/issue-3029
Only combine `match` if its condition expression fits in a single line
Diffstat (limited to 'src')
| -rw-r--r-- | src/overflow.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/overflow.rs b/src/overflow.rs index a7fc9728666..40cfc4be30f 100644 --- a/src/overflow.rs +++ b/src/overflow.rs @@ -18,6 +18,7 @@ use syntax::{ast, ptr}; use closures; use expr::{ can_be_overflowed_expr, is_every_expr_simple, is_method_call, is_nested_call, is_simple_expr, + rewrite_cond, }; use lists::{definitive_tactic, itemize_list, write_list, ListFormatting, ListItem, Separator}; use macros::MacroArg; @@ -403,6 +404,16 @@ impl<'a> Context<'a> { closures::rewrite_last_closure(self.context, expr, shape) } } + ast::ExprKind::Match(..) => { + let multi_line = rewrite_cond(self.context, expr, shape) + .map_or(false, |cond| cond.contains('\n')); + + if multi_line { + None + } else { + expr.rewrite(self.context, shape) + } + } _ => expr.rewrite(self.context, shape), } } |
