@@ -3573,7 +3573,8 @@ impl<'a> Parser<'a> {
3573
3573
} else {
3574
3574
self . restrictions
3575
3575
} ;
3576
- if op. precedence ( ) < min_prec {
3576
+ let prec = op. precedence ( ) ;
3577
+ if prec < min_prec {
3577
3578
break ;
3578
3579
}
3579
3580
// Check for deprecated `...` syntax
@@ -3614,8 +3615,7 @@ impl<'a> Parser<'a> {
3614
3615
// We have 2 alternatives here: `x..y`/`x..=y` and `x..`/`x..=` The other
3615
3616
// two variants are handled with `parse_prefix_range_expr` call above.
3616
3617
let rhs = if self . is_at_start_of_range_notation_rhs ( ) {
3617
- Some ( self . parse_assoc_expr_with ( op. precedence ( ) + 1 ,
3618
- LhsExpr :: NotYetParsed ) ?)
3618
+ Some ( self . parse_assoc_expr_with ( prec + 1 , LhsExpr :: NotYetParsed ) ?)
3619
3619
} else {
3620
3620
None
3621
3621
} ;
@@ -3635,28 +3635,18 @@ impl<'a> Parser<'a> {
3635
3635
break
3636
3636
}
3637
3637
3638
- let rhs = match op. fixity ( ) {
3639
- Fixity :: Right => self . with_res (
3640
- restrictions - Restrictions :: STMT_EXPR ,
3641
- |this| {
3642
- this. parse_assoc_expr_with ( op. precedence ( ) ,
3643
- LhsExpr :: NotYetParsed )
3644
- } ) ,
3645
- Fixity :: Left => self . with_res (
3646
- restrictions - Restrictions :: STMT_EXPR ,
3647
- |this| {
3648
- this. parse_assoc_expr_with ( op. precedence ( ) + 1 ,
3649
- LhsExpr :: NotYetParsed )
3650
- } ) ,
3638
+ let fixity = op. fixity ( ) ;
3639
+ let prec_adjustment = match fixity {
3640
+ Fixity :: Right => 0 ,
3641
+ Fixity :: Left => 1 ,
3651
3642
// We currently have no non-associative operators that are not handled above by
3652
3643
// the special cases. The code is here only for future convenience.
3653
- Fixity :: None => self . with_res (
3654
- restrictions - Restrictions :: STMT_EXPR ,
3655
- |this| {
3656
- this. parse_assoc_expr_with ( op. precedence ( ) + 1 ,
3657
- LhsExpr :: NotYetParsed )
3658
- } ) ,
3659
- } ?;
3644
+ Fixity :: None => 1 ,
3645
+ } ;
3646
+ let rhs = self . with_res (
3647
+ restrictions - Restrictions :: STMT_EXPR ,
3648
+ |this| this. parse_assoc_expr_with ( prec + prec_adjustment, LhsExpr :: NotYetParsed )
3649
+ ) ?;
3660
3650
3661
3651
// Make sure that the span of the parent node is larger than the span of lhs and rhs,
3662
3652
// including the attributes.
@@ -3702,7 +3692,7 @@ impl<'a> Parser<'a> {
3702
3692
}
3703
3693
} ;
3704
3694
3705
- if op . fixity ( ) == Fixity :: None { break }
3695
+ if let Fixity :: None = fixity { break }
3706
3696
}
3707
3697
Ok ( lhs)
3708
3698
}
0 commit comments