mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-23 21:23:20 +00:00
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.print_expr_cond_paren(
|
||||
expr,
|
||||
Self::cond_needs_par(expr)
|
||||
|| parser::needs_par_as_let_scrutinee(expr.precedence().order()),
|
||||
match expr.kind {
|
||||
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 {}`
|
||||
/// 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 {
|
||||
ast::ExprKind::Break(..)
|
||||
| ast::ExprKind::Closure(..)
|
||||
|
Loading…
Reference in New Issue
Block a user