diff options
| author | Kevin Stenerson <kstenerson@developers.wyyerd.com> | 2018-11-05 21:12:40 -0700 |
|---|---|---|
| committer | Kevin Stenerson <kstenerson@developers.wyyerd.com> | 2018-11-05 21:12:40 -0700 |
| commit | 25b828d35fc4072a860cd504dfa051747b4487a4 (patch) | |
| tree | 5fea3443eea16f379e622d50dc72fc10f8866158 /src/expr.rs | |
| parent | 16d5f507b63da32783bc920a33e39580d35e492a (diff) | |
Add config option to more aggressively allow overflow
Diffstat (limited to 'src/expr.rs')
| -rw-r--r-- | src/expr.rs | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/src/expr.rs b/src/expr.rs index 08b9ad3079c..502c42ff213 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -1343,12 +1343,31 @@ pub fn can_be_overflowed_expr(context: &RewriteContext, expr: &ast::Expr, args_l ast::ExprKind::Block(..) | ast::ExprKind::Closure(..) => { context.use_block_indent() || context.config.indent_style() == IndentStyle::Visual } - ast::ExprKind::Array(..) - | ast::ExprKind::Call(..) - | ast::ExprKind::Mac(..) - | ast::ExprKind::MethodCall(..) - | ast::ExprKind::Struct(..) - | ast::ExprKind::Tup(..) => context.use_block_indent() && args_len == 1, + + // Handle `[]` and `{}`-like expressions + ast::ExprKind::Array(..) | ast::ExprKind::Struct(..) => { + if context.config.overflow_delimited_expr() { + context.use_block_indent() || context.config.indent_style() == IndentStyle::Visual + } else { + context.use_block_indent() && args_len == 1 + } + } + ast::ExprKind::Mac(ref macro_) => { + match (macro_.node.delim, context.config.overflow_delimited_expr()) { + (ast::MacDelimiter::Bracket, true) | (ast::MacDelimiter::Brace, true) => { + context.use_block_indent() + || context.config.indent_style() == IndentStyle::Visual + } + _ => context.use_block_indent() && args_len == 1, + } + } + + // Handle parenthetical expressions + ast::ExprKind::Call(..) | ast::ExprKind::MethodCall(..) | ast::ExprKind::Tup(..) => { + context.use_block_indent() && args_len == 1 + } + + // Handle unary-like expressions ast::ExprKind::AddrOf(_, ref expr) | ast::ExprKind::Box(ref expr) | ast::ExprKind::Try(ref expr) |
