about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDavid Tolnay <dtolnay@gmail.com>2024-12-20 19:47:49 -0800
committerDavid Tolnay <dtolnay@gmail.com>2024-12-20 20:12:20 -0800
commitd748d1d9533bac2a29371b8154acebebaf588ca1 (patch)
tree46f3140d2a904dc1f56c815bb85b3c3c5413bf8f
parent13170cd787cb733ed24842ee825bcbd98dc01476 (diff)
downloadrust-d748d1d9533bac2a29371b8154acebebaf588ca1.tar.gz
rust-d748d1d9533bac2a29371b8154acebebaf588ca1.zip
Add some parenthesization test cases with operators that are not left-associative
-rw-r--r--tests/ui-fulldeps/pprust-parenthesis-insertion.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/ui-fulldeps/pprust-parenthesis-insertion.rs b/tests/ui-fulldeps/pprust-parenthesis-insertion.rs
index 184458bad55..8b76eb7b606 100644
--- a/tests/ui-fulldeps/pprust-parenthesis-insertion.rs
+++ b/tests/ui-fulldeps/pprust-parenthesis-insertion.rs
@@ -61,6 +61,9 @@ static EXPRS: &[&str] = &[
     "(2 + 2) * 2",
     "2 * (2 + 2)",
     "2 + 2 + 2",
+    // Right-associative operator.
+    "2 += 2 += 2",
+    "(2 += 2) += 2",
     // Return has lower precedence than a binary operator.
     "(return 2) + 2",
     "2 + (return 2)", // FIXME: no parenthesis needed.
@@ -89,6 +92,11 @@ static EXPRS: &[&str] = &[
     // allowed, except if the break is also labeled.
     "break 'outer 'inner: loop {} + 2",
     "break ('inner: loop {} + 2)",
+    // Grammar restriction: ranges cannot be the endpoint of another range.
+    "(2..2)..2",
+    "2..(2..2)",
+    "(2..2)..",
+    "..(2..2)",
     // Grammar restriction: the value in let-else is not allowed to end in a
     // curly brace.
     "{ let _ = 1 + 1 else {}; }",