Fix breaking changes from rustc-ap-syntax
cc https://github.com/rust-lang/rust/pull/50045.
This commit is contained in:
parent
82e81d7ed1
commit
912e4bdc90
@ -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<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) =>
|
||||
{
|
||||
|
@ -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')
|
||||
|
@ -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<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),
|
||||
|
Loading…
x
Reference in New Issue
Block a user