File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed
compiler/rustc_ast_pretty/src/pprust Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -1161,8 +1161,13 @@ impl<'a> State<'a> {
11611161 self . word_space ( "=" ) ;
11621162 self . print_expr_cond_paren (
11631163 expr,
1164- Self :: cond_needs_par ( expr)
1165- || parser:: needs_par_as_let_scrutinee ( expr. precedence ( ) . order ( ) ) ,
1164+ match expr. kind {
1165+ ast:: ExprKind :: Break ( ..)
1166+ | ast:: ExprKind :: Closure ( ..)
1167+ | ast:: ExprKind :: Ret ( ..)
1168+ | ast:: ExprKind :: Yeet ( ..) => true ,
1169+ _ => parser:: contains_exterior_struct_lit ( expr) ,
1170+ } || parser:: needs_par_as_let_scrutinee ( expr. precedence ( ) . order ( ) ) ,
11661171 ) ;
11671172 }
11681173
Original file line number Diff line number Diff line change @@ -69,7 +69,7 @@ impl<'a> State<'a> {
6969 ///
7070 /// These cases need parens due to the parse error observed in #26461: `if return {}`
7171 /// parses as the erroneous construct `if (return {})`, not `if (return) {}`.
72- pub ( super ) fn cond_needs_par ( expr : & ast:: Expr ) -> bool {
72+ fn cond_needs_par ( expr : & ast:: Expr ) -> bool {
7373 match expr. kind {
7474 ast:: ExprKind :: Break ( ..)
7575 | ast:: ExprKind :: Closure ( ..)
You can’t perform that action at this time.
0 commit comments