-fn rewrite_match_pattern(
- context: &RewriteContext,
- pats: &[&ast::Pat],
- guard: &Option<ptr::P<ast::Expr>>,
- has_beginning_vert: bool,
- shape: Shape,
-) -> Option<String> {
- // Patterns
- // 5 = ` => {`
- // 2 = `| `
- let pat_shape = shape
- .sub_width(5)?
- .offset_left(if has_beginning_vert { 2 } else { 0 })?;
- let pats_str = rewrite_multiple_patterns(context, pats, pat_shape)?;
- let beginning_vert = if has_beginning_vert { "| " } else { "" };
-
- // Guard
- let guard_str = rewrite_guard(context, guard, shape, trimmed_last_line_width(&pats_str))?;
-
- Some(format!("{}{}{}", beginning_vert, pats_str, guard_str))
+fn block_can_be_flattened<'a>(
+ context: &RewriteContext<'_>,
+ expr: &'a ast::Expr,
+) -> Option<&'a ast::Block> {
+ match expr.kind {
+ ast::ExprKind::Block(ref block, _)
+ if !is_unsafe_block(block)
+ && !context.inside_macro()
+ && is_simple_block(context, block, Some(&expr.attrs)) =>
+ {
+ Some(&*block)
+ }
+ _ => None,
+ }