File tree 2 files changed +8
-3
lines changed
compiler/rustc_ast_pretty/src/pprust
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> {
1161
1161
self . word_space ( "=" ) ;
1162
1162
self . print_expr_cond_paren (
1163
1163
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 ( ) ) ,
1166
1171
) ;
1167
1172
}
1168
1173
Original file line number Diff line number Diff line change @@ -69,7 +69,7 @@ impl<'a> State<'a> {
69
69
///
70
70
/// These cases need parens due to the parse error observed in #26461: `if return {}`
71
71
/// 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 {
73
73
match expr. kind {
74
74
ast:: ExprKind :: Break ( ..)
75
75
| ast:: ExprKind :: Closure ( ..)
You can’t perform that action at this time.
0 commit comments