Skip to content

Commit d748d1d

Browse files
committed
Add some parenthesization test cases with operators that are not left-associative
1 parent 13170cd commit d748d1d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

tests/ui-fulldeps/pprust-parenthesis-insertion.rs

+8
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ static EXPRS: &[&str] = &[
6161
"(2 + 2) * 2",
6262
"2 * (2 + 2)",
6363
"2 + 2 + 2",
64+
// Right-associative operator.
65+
"2 += 2 += 2",
66+
"(2 += 2) += 2",
6467
// Return has lower precedence than a binary operator.
6568
"(return 2) + 2",
6669
"2 + (return 2)", // FIXME: no parenthesis needed.
@@ -89,6 +92,11 @@ static EXPRS: &[&str] = &[
8992
// allowed, except if the break is also labeled.
9093
"break 'outer 'inner: loop {} + 2",
9194
"break ('inner: loop {} + 2)",
95+
// Grammar restriction: ranges cannot be the endpoint of another range.
96+
"(2..2)..2",
97+
"2..(2..2)",
98+
"(2..2)..",
99+
"..(2..2)",
92100
// Grammar restriction: the value in let-else is not allowed to end in a
93101
// curly brace.
94102
"{ let _ = 1 + 1 else {}; }",

0 commit comments

Comments
 (0)