File tree Expand file tree Collapse file tree 2 files changed +14
-17
lines changed Expand file tree Collapse file tree 2 files changed +14
-17
lines changed Original file line number Diff line number Diff line change @@ -2292,12 +2292,6 @@ fn expr_precedence(expr: &hir::Expr) -> i8 {
22922292 hir:: ExprRet ( ..) |
22932293 hir:: ExprYield ( ..) => PREC_JUMP ,
22942294
2295- hir:: ExprIf ( ..) |
2296- hir:: ExprWhile ( ..) |
2297- hir:: ExprLoop ( ..) |
2298- hir:: ExprMatch ( ..) |
2299- hir:: ExprBlock ( ..) => PREC_BLOCK ,
2300-
23012295 // Binop-like expr kinds, handled by `AssocOp`.
23022296 hir:: ExprBinary ( op, _, _) => bin_op_to_assoc_op ( op. node ) . precedence ( ) as i8 ,
23032297
@@ -2326,6 +2320,11 @@ fn expr_precedence(expr: &hir::Expr) -> i8 {
23262320 hir:: ExprTup ( ..) |
23272321 hir:: ExprLit ( ..) |
23282322 hir:: ExprPath ( ..) |
2323+ hir:: ExprIf ( ..) |
2324+ hir:: ExprWhile ( ..) |
2325+ hir:: ExprLoop ( ..) |
2326+ hir:: ExprMatch ( ..) |
2327+ hir:: ExprBlock ( ..) |
23292328 hir:: ExprStruct ( ..) => PREC_PAREN ,
23302329 }
23312330}
Original file line number Diff line number Diff line change @@ -219,7 +219,6 @@ impl AssocOp {
219219pub const PREC_RESET : i8 = -100 ;
220220pub const PREC_CLOSURE : i8 = -40 ;
221221pub const PREC_JUMP : i8 = -30 ;
222- pub const PREC_BLOCK : i8 = -20 ;
223222pub const PREC_RANGE : i8 = -10 ;
224223// The range 2 ... 14 is reserved for AssocOp binary operator precedences.
225224pub const PREC_PREFIX : i8 = 50 ;
@@ -236,16 +235,6 @@ pub fn expr_precedence(expr: &ast::Expr) -> i8 {
236235 ExprKind :: Ret ( ..) |
237236 ExprKind :: Yield ( ..) => PREC_JUMP ,
238237
239- ExprKind :: If ( ..) |
240- ExprKind :: IfLet ( ..) |
241- ExprKind :: While ( ..) |
242- ExprKind :: WhileLet ( ..) |
243- ExprKind :: ForLoop ( ..) |
244- ExprKind :: Loop ( ..) |
245- ExprKind :: Match ( ..) |
246- ExprKind :: Block ( ..) |
247- ExprKind :: Catch ( ..) => PREC_BLOCK ,
248-
249238 // `Range` claims to have higher precedence than `Assign`, but `x .. x = x` fails to parse,
250239 // instead of parsing as `(x .. x) = x`. Giving `Range` a lower precedence ensures that
251240 // `pprust` will add parentheses in the right places to get the desired parse.
@@ -284,6 +273,15 @@ pub fn expr_precedence(expr: &ast::Expr) -> i8 {
284273 ExprKind :: Lit ( ..) |
285274 ExprKind :: Path ( ..) |
286275 ExprKind :: Paren ( ..) |
276+ ExprKind :: If ( ..) |
277+ ExprKind :: IfLet ( ..) |
278+ ExprKind :: While ( ..) |
279+ ExprKind :: WhileLet ( ..) |
280+ ExprKind :: ForLoop ( ..) |
281+ ExprKind :: Loop ( ..) |
282+ ExprKind :: Match ( ..) |
283+ ExprKind :: Block ( ..) |
284+ ExprKind :: Catch ( ..) |
287285 ExprKind :: Struct ( ..) => PREC_PAREN ,
288286 }
289287}
You can’t perform that action at this time.
0 commit comments