Skip to content

Commit 912e4bd

Browse files
committed
Fix breaking changes from rustc-ap-syntax
cc rust-lang/rust#50045.
1 parent 82e81d7 commit 912e4bd

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

src/closures.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub fn rewrite_closure(
4747
// 1 = space between `|...|` and body.
4848
let body_shape = shape.offset_left(extra_offset)?;
4949

50-
if let ast::ExprKind::Block(ref block) = body.node {
50+
if let ast::ExprKind::Block(ref block, _) = body.node {
5151
// The body of the closure is an empty block.
5252
if block.stmts.is_empty() && !block_contains_comment(block, context.codemap) {
5353
return body
@@ -96,7 +96,7 @@ fn get_inner_expr<'a>(
9696
prefix: &str,
9797
context: &RewriteContext,
9898
) -> &'a ast::Expr {
99-
if let ast::ExprKind::Block(ref block) = expr.node {
99+
if let ast::ExprKind::Block(ref block, _) = expr.node {
100100
if !needs_block(block, prefix, context) {
101101
// block.stmts.len() == 1
102102
if let Some(expr) = stmt_expr(&block.stmts[0]) {
@@ -289,7 +289,7 @@ pub fn rewrite_last_closure(
289289
) -> Option<String> {
290290
if let ast::ExprKind::Closure(capture, movability, ref fn_decl, ref body, _) = expr.node {
291291
let body = match body.node {
292-
ast::ExprKind::Block(ref block)
292+
ast::ExprKind::Block(ref block, _)
293293
if !is_unsafe_block(block)
294294
&& is_simple_block(block, Some(&body.attrs), context.codemap) =>
295295
{

src/expr.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ pub fn format_expr(
118118
| ast::ExprKind::While(..)
119119
| ast::ExprKind::WhileLet(..) => to_control_flow(expr, expr_type)
120120
.and_then(|control_flow| control_flow.rewrite(context, shape)),
121-
ast::ExprKind::Block(ref block) => {
121+
// FIXME(topecongiro): Handle label on a block (#2722).
122+
ast::ExprKind::Block(ref block, _) => {
122123
match expr_type {
123124
ExprType::Statement => {
124125
if is_unsafe_block(block) {
@@ -880,7 +881,7 @@ impl<'a> ControlFlow<'a> {
880881
let else_block = self.else_block?;
881882
let fixed_cost = self.keyword.len() + " { } else { }".len();
882883

883-
if let ast::ExprKind::Block(ref else_node) = else_block.node {
884+
if let ast::ExprKind::Block(ref else_node, _) = else_block.node {
884885
if !is_simple_block(self.block, None, context.codemap)
885886
|| !is_simple_block(else_node, None, context.codemap)
886887
|| pat_expr_str.contains('\n')

src/matches.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ fn arm_comma(config: &Config, body: &ast::Expr, is_last: bool) -> &'static str {
155155
""
156156
} else if config.match_block_trailing_comma() {
157157
","
158-
} else if let ast::ExprKind::Block(ref block) = body.node {
158+
} else if let ast::ExprKind::Block(ref block, _) = body.node {
159159
if let ast::BlockCheckMode::Default = block.rules {
160160
""
161161
} else {
@@ -308,7 +308,7 @@ fn rewrite_match_pattern(
308308
// @body: flattened body, if the body is block with a single expression
309309
fn flatten_arm_body<'a>(context: &'a RewriteContext, body: &'a ast::Expr) -> (bool, &'a ast::Expr) {
310310
match body.node {
311-
ast::ExprKind::Block(ref block)
311+
ast::ExprKind::Block(ref block, _)
312312
if !is_unsafe_block(block)
313313
&& is_simple_block(block, Some(&body.attrs), context.codemap) =>
314314
{
@@ -337,7 +337,7 @@ fn rewrite_match_body(
337337
is_last: bool,
338338
) -> Option<String> {
339339
let (extend, body) = flatten_arm_body(context, body);
340-
let (is_block, is_empty_block) = if let ast::ExprKind::Block(ref block) = body.node {
340+
let (is_block, is_empty_block) = if let ast::ExprKind::Block(ref block, _) = body.node {
341341
(
342342
true,
343343
is_empty_block(block, Some(&body.attrs), context.codemap),

0 commit comments

Comments
 (0)