From cbe01e47024c852e2ed852671e76f7929c4bab91 Mon Sep 17 00:00:00 2001 From: Caleb Cartwright Date: Mon, 19 Oct 2020 20:26:56 -0500 Subject: [PATCH] feat: add initial support for ConstBlock expressions --- src/formatting/expr.rs | 3 +++ src/formatting/utils.rs | 1 + 2 files changed, 4 insertions(+) diff --git a/src/formatting/expr.rs b/src/formatting/expr.rs index b53496affa8..61937aeee3f 100644 --- a/src/formatting/expr.rs +++ b/src/formatting/expr.rs @@ -124,6 +124,9 @@ pub(crate) fn format_expr( | ast::ExprKind::Loop(..) | ast::ExprKind::While(..) => to_control_flow(expr, expr_type) .and_then(|control_flow| control_flow.rewrite(context, shape)), + ast::ExprKind::ConstBlock(ref anon_const) => { + Some(format!("const {}", anon_const.rewrite(context, shape)?)) + } ast::ExprKind::Block(ref block, opt_label) => { match expr_type { ExprType::Statement => { diff --git a/src/formatting/utils.rs b/src/formatting/utils.rs index f3484020b05..01d4c4b202f 100644 --- a/src/formatting/utils.rs +++ b/src/formatting/utils.rs @@ -482,6 +482,7 @@ pub(crate) fn is_block_expr(context: &RewriteContext<'_>, expr: &ast::Expr, repr | ast::ExprKind::While(..) | ast::ExprKind::If(..) | ast::ExprKind::Block(..) + | ast::ExprKind::ConstBlock(..) | ast::ExprKind::Async(..) | ast::ExprKind::Loop(..) | ast::ExprKind::ForLoop(..)