Inline cond_needs_par into print_let
This commit is contained in:
parent
d2b7bd4774
commit
8d64961589
@ -1161,8 +1161,13 @@ impl<'a> State<'a> {
|
|||||||
self.word_space("=");
|
self.word_space("=");
|
||||||
self.print_expr_cond_paren(
|
self.print_expr_cond_paren(
|
||||||
expr,
|
expr,
|
||||||
Self::cond_needs_par(expr)
|
match expr.kind {
|
||||||
|| parser::needs_par_as_let_scrutinee(expr.precedence().order()),
|
ast::ExprKind::Break(..)
|
||||||
|
| ast::ExprKind::Closure(..)
|
||||||
|
| ast::ExprKind::Ret(..)
|
||||||
|
| ast::ExprKind::Yeet(..) => true,
|
||||||
|
_ => parser::contains_exterior_struct_lit(expr),
|
||||||
|
} || parser::needs_par_as_let_scrutinee(expr.precedence().order()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ impl<'a> State<'a> {
|
|||||||
///
|
///
|
||||||
/// These cases need parens due to the parse error observed in #26461: `if return {}`
|
/// These cases need parens due to the parse error observed in #26461: `if return {}`
|
||||||
/// parses as the erroneous construct `if (return {})`, not `if (return) {}`.
|
/// parses as the erroneous construct `if (return {})`, not `if (return) {}`.
|
||||||
pub(super) fn cond_needs_par(expr: &ast::Expr) -> bool {
|
fn cond_needs_par(expr: &ast::Expr) -> bool {
|
||||||
match expr.kind {
|
match expr.kind {
|
||||||
ast::ExprKind::Break(..)
|
ast::ExprKind::Break(..)
|
||||||
| ast::ExprKind::Closure(..)
|
| ast::ExprKind::Closure(..)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user