diff --git a/src/closures.rs b/src/closures.rs index aec7d34b60a..dc811ea95ad 100644 --- a/src/closures.rs +++ b/src/closures.rs @@ -47,7 +47,7 @@ pub fn rewrite_closure( // 1 = space between `|...|` and body. let body_shape = shape.offset_left(extra_offset)?; - if let ast::ExprKind::Block(ref block) = body.node { + if let ast::ExprKind::Block(ref block, _) = body.node { // The body of the closure is an empty block. if block.stmts.is_empty() && !block_contains_comment(block, context.codemap) { return body @@ -96,7 +96,7 @@ fn get_inner_expr<'a>( prefix: &str, context: &RewriteContext, ) -> &'a ast::Expr { - if let ast::ExprKind::Block(ref block) = expr.node { + if let ast::ExprKind::Block(ref block, _) = expr.node { if !needs_block(block, prefix, context) { // block.stmts.len() == 1 if let Some(expr) = stmt_expr(&block.stmts[0]) { @@ -289,7 +289,7 @@ pub fn rewrite_last_closure( ) -> Option { if let ast::ExprKind::Closure(capture, movability, ref fn_decl, ref body, _) = expr.node { let body = match body.node { - ast::ExprKind::Block(ref block) + ast::ExprKind::Block(ref block, _) if !is_unsafe_block(block) && is_simple_block(block, Some(&body.attrs), context.codemap) => { diff --git a/src/expr.rs b/src/expr.rs index 17d9b95d841..8961cec4240 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -118,7 +118,8 @@ pub fn format_expr( | ast::ExprKind::While(..) | ast::ExprKind::WhileLet(..) => to_control_flow(expr, expr_type) .and_then(|control_flow| control_flow.rewrite(context, shape)), - ast::ExprKind::Block(ref block) => { + // FIXME(topecongiro): Handle label on a block (#2722). + ast::ExprKind::Block(ref block, _) => { match expr_type { ExprType::Statement => { if is_unsafe_block(block) { @@ -880,7 +881,7 @@ impl<'a> ControlFlow<'a> { let else_block = self.else_block?; let fixed_cost = self.keyword.len() + " { } else { }".len(); - if let ast::ExprKind::Block(ref else_node) = else_block.node { + if let ast::ExprKind::Block(ref else_node, _) = else_block.node { if !is_simple_block(self.block, None, context.codemap) || !is_simple_block(else_node, None, context.codemap) || pat_expr_str.contains('\n') diff --git a/src/matches.rs b/src/matches.rs index 5a6aa6c6aac..9551dc36002 100644 --- a/src/matches.rs +++ b/src/matches.rs @@ -155,7 +155,7 @@ fn arm_comma(config: &Config, body: &ast::Expr, is_last: bool) -> &'static str { "" } else if config.match_block_trailing_comma() { "," - } else if let ast::ExprKind::Block(ref block) = body.node { + } else if let ast::ExprKind::Block(ref block, _) = body.node { if let ast::BlockCheckMode::Default = block.rules { "" } else { @@ -308,7 +308,7 @@ fn rewrite_match_pattern( // @body: flattened body, if the body is block with a single expression fn flatten_arm_body<'a>(context: &'a RewriteContext, body: &'a ast::Expr) -> (bool, &'a ast::Expr) { match body.node { - ast::ExprKind::Block(ref block) + ast::ExprKind::Block(ref block, _) if !is_unsafe_block(block) && is_simple_block(block, Some(&body.attrs), context.codemap) => { @@ -337,7 +337,7 @@ fn rewrite_match_body( is_last: bool, ) -> Option { let (extend, body) = flatten_arm_body(context, body); - let (is_block, is_empty_block) = if let ast::ExprKind::Block(ref block) = body.node { + let (is_block, is_empty_block) = if let ast::ExprKind::Block(ref block, _) = body.node { ( true, is_empty_block(block, Some(&body.attrs), context.codemap),