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 {
1400
1400
if precedence < base {
1401
1401
break ;
1402
1402
}
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
+ }
1403
1410
input. advance_to ( & ahead) ;
1404
1411
let right = parse_binop_rhs ( input, allow_struct, precedence) ?;
1405
1412
lhs = Expr :: Binary ( ExprBinary {
@@ -1455,6 +1462,13 @@ pub(crate) mod parsing {
1455
1462
if precedence < base {
1456
1463
break ;
1457
1464
}
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
+ }
1458
1472
input. advance_to ( & ahead) ;
1459
1473
let right = parse_binop_rhs ( input, precedence) ?;
1460
1474
lhs = Expr :: Binary ( ExprBinary {
Original file line number Diff line number Diff line change @@ -605,18 +605,8 @@ fn test_binop_associativity() {
605
605
}
606
606
"### ) ;
607
607
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 ( ) ;
620
610
}
621
611
622
612
#[ test]
You can’t perform that action at this time.
0 commit comments