File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -576,3 +576,34 @@ fn test_tuple_comma() {
576
576
}
577
577
"### ) ;
578
578
}
579
+
580
+ #[ test]
581
+ fn test_assign_range_precedence ( ) {
582
+ // Range has higher precedence as the right-hand of an assignment, but
583
+ // ambiguous precedence as the left-hand of an assignment.
584
+ snapshot ! ( "() = () .. ()" as Expr , @r###"
585
+ Expr::Assign {
586
+ left: Expr::Tuple,
587
+ right: Expr::Range {
588
+ start: Some(Expr::Tuple),
589
+ limits: RangeLimits::HalfOpen,
590
+ end: Some(Expr::Tuple),
591
+ },
592
+ }
593
+ "### ) ;
594
+
595
+ snapshot ! ( "() += () .. ()" as Expr , @r###"
596
+ Expr::Binary {
597
+ left: Expr::Tuple,
598
+ op: BinOp::AddAssign,
599
+ right: Expr::Range {
600
+ start: Some(Expr::Tuple),
601
+ limits: RangeLimits::HalfOpen,
602
+ end: Some(Expr::Tuple),
603
+ },
604
+ }
605
+ "### ) ;
606
+
607
+ syn:: parse_str :: < Expr > ( "() .. () = ()" ) . unwrap_err ( ) ;
608
+ syn:: parse_str :: < Expr > ( "() .. () += ()" ) . unwrap_err ( ) ;
609
+ }
You can’t perform that action at this time.
0 commit comments