We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
match
1 parent 13471d3 commit 832b33eCopy full SHA for 832b33e
compiler/rustc_ast_pretty/src/pprust/state/expr.rs
@@ -244,6 +244,10 @@ impl<'a> State<'a> {
244
(&ast::ExprKind::Let { .. }, _) if !parser::needs_par_as_let_scrutinee(prec) => {
245
parser::PREC_FORCE_PAREN
246
}
247
+ // For a binary expression like `(match () { _ => a }) OP b`, the parens are required
248
+ // otherwise the parser would interpret `match () { _ => a }` as a statement,
249
+ // with the remaining `OP b` not making sense. So we force parens.
250
+ (&ast::ExprKind::Match(..), _) => parser::PREC_FORCE_PAREN,
251
_ => left_prec,
252
};
253
0 commit comments