Skip to content

Commit

Permalink
Fix breaking changes from rustc-ap-syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
topecongiro committed May 18, 2018
1 parent 82e81d7 commit 912e4bd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/closures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]) {
Expand Down Expand Up @@ -289,7 +289,7 @@ pub fn rewrite_last_closure(
) -> Option<String> {
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) =>
{
Expand Down
5 changes: 3 additions & 2 deletions src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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')
Expand Down
6 changes: 3 additions & 3 deletions src/matches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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) =>
{
Expand Down Expand Up @@ -337,7 +337,7 @@ fn rewrite_match_body(
is_last: bool,
) -> Option<String> {
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),
Expand Down

0 comments on commit 912e4bd

Please sign in to comment.