diff options
Diffstat (limited to 'compiler/rustc_ast_pretty/src/pprust/state/expr.rs')
-rw-r--r-- | compiler/rustc_ast_pretty/src/pprust/state/expr.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/compiler/rustc_ast_pretty/src/pprust/state/expr.rs b/compiler/rustc_ast_pretty/src/pprust/state/expr.rs index cacfe9eb2..776bf5424 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state/expr.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state/expr.rs @@ -244,6 +244,10 @@ impl<'a> State<'a> { (&ast::ExprKind::Let { .. }, _) if !parser::needs_par_as_let_scrutinee(prec) => { parser::PREC_FORCE_PAREN } + // For a binary expression like `(match () { _ => a }) OP b`, the parens are required + // otherwise the parser would interpret `match () { _ => a }` as a statement, + // with the remaining `OP b` not making sense. So we force parens. + (&ast::ExprKind::Match(..), _) => parser::PREC_FORCE_PAREN, _ => left_prec, }; @@ -292,10 +296,6 @@ impl<'a> State<'a> { self.ibox(INDENT_UNIT); self.ann.pre(self, AnnNode::Expr(expr)); match &expr.kind { - ast::ExprKind::Box(expr) => { - self.word_space("box"); - self.print_expr_maybe_paren(expr, parser::PREC_PREFIX); - } ast::ExprKind::Array(exprs) => { self.print_expr_vec(exprs); } @@ -439,7 +439,7 @@ impl<'a> State<'a> { self.ibox(0); self.print_block_with_attrs(blk, attrs); } - ast::ExprKind::Async(capture_clause, _, blk) => { + ast::ExprKind::Async(capture_clause, blk) => { self.word_nbsp("async"); self.print_capture_clause(*capture_clause); // cbox/ibox in analogy to the `ExprKind::Block` arm above |