File tree Expand file tree Collapse file tree 2 files changed +16
-12
lines changed Expand file tree Collapse file tree 2 files changed +16
-12
lines changed Original file line number Diff line number Diff line change @@ -1400,6 +1400,13 @@ pub(crate) mod parsing {
14001400 if precedence < base {
14011401 break ;
14021402 }
1403+ if precedence == Precedence :: Compare {
1404+ if let Expr :: Binary ( lhs) = & lhs {
1405+ if Precedence :: of ( & lhs. op ) == Precedence :: Compare {
1406+ break ;
1407+ }
1408+ }
1409+ }
14031410 input. advance_to ( & ahead) ;
14041411 let right = parse_binop_rhs ( input, allow_struct, precedence) ?;
14051412 lhs = Expr :: Binary ( ExprBinary {
@@ -1455,6 +1462,13 @@ pub(crate) mod parsing {
14551462 if precedence < base {
14561463 break ;
14571464 }
1465+ if precedence == Precedence :: Compare {
1466+ if let Expr :: Binary ( lhs) = & lhs {
1467+ if Precedence :: of ( & lhs. op ) == Precedence :: Compare {
1468+ break ;
1469+ }
1470+ }
1471+ }
14581472 input. advance_to ( & ahead) ;
14591473 let right = parse_binop_rhs ( input, precedence) ?;
14601474 lhs = Expr :: Binary ( ExprBinary {
Original file line number Diff line number Diff line change @@ -605,18 +605,8 @@ fn test_binop_associativity() {
605605 }
606606 "### ) ;
607607
608- // FIXME: this should fail to parse. Parenthesization is required.
609- snapshot ! ( "() == () == ()" as Expr , @r###"
610- Expr::Binary {
611- left: Expr::Binary {
612- left: Expr::Tuple,
613- op: BinOp::Eq,
614- right: Expr::Tuple,
615- },
616- op: BinOp::Eq,
617- right: Expr::Tuple,
618- }
619- "### ) ;
608+ // Parenthesization is required.
609+ syn:: parse_str :: < Expr > ( "() == () == ()" ) . unwrap_err ( ) ;
620610}
621611
622612#[ test]
You can’t perform that action at this time.
0 commit comments