File tree 2 files changed +14
-17
lines changed
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 {
2292
2292
hir:: ExprRet ( ..) |
2293
2293
hir:: ExprYield ( ..) => PREC_JUMP ,
2294
2294
2295
- hir:: ExprIf ( ..) |
2296
- hir:: ExprWhile ( ..) |
2297
- hir:: ExprLoop ( ..) |
2298
- hir:: ExprMatch ( ..) |
2299
- hir:: ExprBlock ( ..) => PREC_BLOCK ,
2300
-
2301
2295
// Binop-like expr kinds, handled by `AssocOp`.
2302
2296
hir:: ExprBinary ( op, _, _) => bin_op_to_assoc_op ( op. node ) . precedence ( ) as i8 ,
2303
2297
@@ -2326,6 +2320,11 @@ fn expr_precedence(expr: &hir::Expr) -> i8 {
2326
2320
hir:: ExprTup ( ..) |
2327
2321
hir:: ExprLit ( ..) |
2328
2322
hir:: ExprPath ( ..) |
2323
+ hir:: ExprIf ( ..) |
2324
+ hir:: ExprWhile ( ..) |
2325
+ hir:: ExprLoop ( ..) |
2326
+ hir:: ExprMatch ( ..) |
2327
+ hir:: ExprBlock ( ..) |
2329
2328
hir:: ExprStruct ( ..) => PREC_PAREN ,
2330
2329
}
2331
2330
}
Original file line number Diff line number Diff line change @@ -219,7 +219,6 @@ impl AssocOp {
219
219
pub const PREC_RESET : i8 = -100 ;
220
220
pub const PREC_CLOSURE : i8 = -40 ;
221
221
pub const PREC_JUMP : i8 = -30 ;
222
- pub const PREC_BLOCK : i8 = -20 ;
223
222
pub const PREC_RANGE : i8 = -10 ;
224
223
// The range 2 ... 14 is reserved for AssocOp binary operator precedences.
225
224
pub const PREC_PREFIX : i8 = 50 ;
@@ -236,16 +235,6 @@ pub fn expr_precedence(expr: &ast::Expr) -> i8 {
236
235
ExprKind :: Ret ( ..) |
237
236
ExprKind :: Yield ( ..) => PREC_JUMP ,
238
237
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
-
249
238
// `Range` claims to have higher precedence than `Assign`, but `x .. x = x` fails to parse,
250
239
// instead of parsing as `(x .. x) = x`. Giving `Range` a lower precedence ensures that
251
240
// `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 {
284
273
ExprKind :: Lit ( ..) |
285
274
ExprKind :: Path ( ..) |
286
275
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 ( ..) |
287
285
ExprKind :: Struct ( ..) => PREC_PAREN ,
288
286
}
289
287
}
You can’t perform that action at this time.
0 commit comments