about summary refs log tree commit diff
path: root/src/test/ui/parser
diff options
context:
space:
mode:
authoryukang <moorekang@gmail.com>2022-11-26 07:10:04 +0800
committeryukang <moorekang@gmail.com>2022-11-26 17:08:25 +0800
commitded10a13d2a0ccb4475cb7a330179a1f39e2b4ff (patch)
treeb5d6d45c0c5476df20f017ea4c902b589771a126 /src/test/ui/parser
parentdee85a391f091f314a24fb5a090f2e528f4eb81c (diff)
downloadrust-ded10a13d2a0ccb4475cb7a330179a1f39e2b4ff.tar.gz
rust-ded10a13d2a0ccb4475cb7a330179a1f39e2b4ff.zip
will not suggest for postfix operator when can not handle precedences well
Diffstat (limited to 'src/test/ui/parser')
-rw-r--r--src/test/ui/parser/issue-104867-inc-dec-2.rs11
-rw-r--r--src/test/ui/parser/issue-104867-inc-dec-2.stderr37
2 files changed, 38 insertions, 10 deletions
diff --git a/src/test/ui/parser/issue-104867-inc-dec-2.rs b/src/test/ui/parser/issue-104867-inc-dec-2.rs
index e64dfbcdc28..a006421a975 100644
--- a/src/test/ui/parser/issue-104867-inc-dec-2.rs
+++ b/src/test/ui/parser/issue-104867-inc-dec-2.rs
@@ -16,6 +16,7 @@ fn test3() {
 fn test4() {
     let mut i = 0;
     let _ = i + i++; //~ ERROR Rust has no postfix increment operator
+    // won't suggest since we can not handle the precedences
 }
 
 fn test5() {
@@ -38,4 +39,14 @@ fn test8() {
     let _ = i++ + ++i; //~ ERROR Rust has no postfix increment operator
 }
 
+fn test9() {
+    let mut i = 0;
+    let _ = (1 + 2 + i)++; //~ ERROR Rust has no postfix increment operator
+}
+
+fn test10() {
+    let mut i = 0;
+    let _ = (i++ + 1) + 2; //~ ERROR Rust has no postfix increment operator
+}
+
 fn main() { }
diff --git a/src/test/ui/parser/issue-104867-inc-dec-2.stderr b/src/test/ui/parser/issue-104867-inc-dec-2.stderr
index 21cfa4e8b78..4e2d0546851 100644
--- a/src/test/ui/parser/issue-104867-inc-dec-2.stderr
+++ b/src/test/ui/parser/issue-104867-inc-dec-2.stderr
@@ -36,14 +36,9 @@ error: Rust has no postfix increment operator
    |
 LL |     let _ = i + i++;
    |                  ^^ not a valid postfix operator
-   |
-help: use `+= 1` instead
-   |
-LL |     let _ = { let tmp = i + i; i + i += 1; tmp };
-   |             +++++++++++      ~~~~~~~~~~~~~~~~~~~
 
 error: Rust has no postfix increment operator
-  --> $DIR/issue-104867-inc-dec-2.rs:23:14
+  --> $DIR/issue-104867-inc-dec-2.rs:24:14
    |
 LL |     let _ = i++ + i;
    |              ^^ not a valid postfix operator
@@ -54,7 +49,7 @@ LL |     let _ = { let tmp = i; i += 1; tmp } + i;
    |             +++++++++++  ~~~~~~~~~~~~~~~
 
 error: Rust has no postfix increment operator
-  --> $DIR/issue-104867-inc-dec-2.rs:28:14
+  --> $DIR/issue-104867-inc-dec-2.rs:29:14
    |
 LL |     let _ = i++ + i++;
    |              ^^ not a valid postfix operator
@@ -65,7 +60,7 @@ LL |     let _ = { let tmp = i; i += 1; tmp } + i++;
    |             +++++++++++  ~~~~~~~~~~~~~~~
 
 error: Rust has no prefix increment operator
-  --> $DIR/issue-104867-inc-dec-2.rs:33:13
+  --> $DIR/issue-104867-inc-dec-2.rs:34:13
    |
 LL |     let _ = ++i + i++;
    |             ^^ not a valid prefix operator
@@ -76,7 +71,7 @@ LL |     let _ = { i += 1; i } + i++;
    |             ~   +++++++++
 
 error: Rust has no postfix increment operator
-  --> $DIR/issue-104867-inc-dec-2.rs:38:14
+  --> $DIR/issue-104867-inc-dec-2.rs:39:14
    |
 LL |     let _ = i++ + ++i;
    |              ^^ not a valid postfix operator
@@ -86,5 +81,27 @@ help: use `+= 1` instead
 LL |     let _ = { let tmp = i; i += 1; tmp } + ++i;
    |             +++++++++++  ~~~~~~~~~~~~~~~
 
-error: aborting due to 8 previous errors
+error: Rust has no postfix increment operator
+  --> $DIR/issue-104867-inc-dec-2.rs:44:24
+   |
+LL |     let _ = (1 + 2 + i)++;
+   |                        ^^ not a valid postfix operator
+   |
+help: use `+= 1` instead
+   |
+LL |     let _ = { let tmp = (1 + 2 + i); (1 + 2 + i) += 1; tmp };
+   |             +++++++++++            ~~~~~~~~~~~~~~~~~~~~~~~~~
+
+error: Rust has no postfix increment operator
+  --> $DIR/issue-104867-inc-dec-2.rs:49:15
+   |
+LL |     let _ = (i++ + 1) + 2;
+   |               ^^ not a valid postfix operator
+   |
+help: use `+= 1` instead
+   |
+LL |     let _ = ({ let tmp = i; i += 1; tmp } + 1) + 2;
+   |              +++++++++++  ~~~~~~~~~~~~~~~
+
+error: aborting due to 10 previous errors