about summary refs log tree commit diff
path: root/src/test/ui/parser
diff options
context:
space:
mode:
authorTheodore Luo Wang <wangtheo662@gmail.com>2021-09-04 22:35:59 -0400
committerTheodore Luo Wang <wangtheo662@gmail.com>2021-09-04 22:35:59 -0400
commit65eb7e516c798a9447dbfe1d02aeeb314d4fec54 (patch)
tree59b304b05a220c76dae75df4119d7809561ae5f5 /src/test/ui/parser
parentbc9877c5af5155174f1a517d41d997b446cc074e (diff)
downloadrust-65eb7e516c798a9447dbfe1d02aeeb314d4fec54.tar.gz
rust-65eb7e516c798a9447dbfe1d02aeeb314d4fec54.zip
Use verbose suggestions and only match if the + is seen before a numeric literal
Diffstat (limited to 'src/test/ui/parser')
-rw-r--r--src/test/ui/parser/expr-as-stmt.fixed4
-rw-r--r--src/test/ui/parser/expr-as-stmt.rs4
-rw-r--r--src/test/ui/parser/expr-as-stmt.stderr8
-rw-r--r--src/test/ui/parser/issue-88276-unary-plus.fixed7
-rw-r--r--src/test/ui/parser/issue-88276-unary-plus.rs9
-rw-r--r--src/test/ui/parser/issue-88276-unary-plus.stderr93
6 files changed, 41 insertions, 84 deletions
diff --git a/src/test/ui/parser/expr-as-stmt.fixed b/src/test/ui/parser/expr-as-stmt.fixed
index 79d73090a04..5f5e25991e0 100644
--- a/src/test/ui/parser/expr-as-stmt.fixed
+++ b/src/test/ui/parser/expr-as-stmt.fixed
@@ -5,7 +5,7 @@
 #![allow(unused_must_use)]
 
 fn foo() -> i32 {
-    ({2}) + {2} //~ ERROR leading `+` is not supported
+    ({2}) + {2} //~ ERROR expected expression, found `+`
     //~^ ERROR mismatched types
 }
 
@@ -16,7 +16,7 @@ fn bar() -> i32 {
 
 fn zul() -> u32 {
     let foo = 3;
-    ({ 42 }) + foo; //~ ERROR leading `+` is not supported
+    ({ 42 }) + foo; //~ ERROR expected expression, found `+`
     //~^ ERROR mismatched types
     32
 }
diff --git a/src/test/ui/parser/expr-as-stmt.rs b/src/test/ui/parser/expr-as-stmt.rs
index 8698f99b81a..5428e1c32fe 100644
--- a/src/test/ui/parser/expr-as-stmt.rs
+++ b/src/test/ui/parser/expr-as-stmt.rs
@@ -5,7 +5,7 @@
 #![allow(unused_must_use)]
 
 fn foo() -> i32 {
-    {2} + {2} //~ ERROR leading `+` is not supported
+    {2} + {2} //~ ERROR expected expression, found `+`
     //~^ ERROR mismatched types
 }
 
@@ -16,7 +16,7 @@ fn bar() -> i32 {
 
 fn zul() -> u32 {
     let foo = 3;
-    { 42 } + foo; //~ ERROR leading `+` is not supported
+    { 42 } + foo; //~ ERROR expected expression, found `+`
     //~^ ERROR mismatched types
     32
 }
diff --git a/src/test/ui/parser/expr-as-stmt.stderr b/src/test/ui/parser/expr-as-stmt.stderr
index 91f97c4662a..d99e9be0000 100644
--- a/src/test/ui/parser/expr-as-stmt.stderr
+++ b/src/test/ui/parser/expr-as-stmt.stderr
@@ -1,8 +1,8 @@
-error: leading `+` is not supported
+error: expected expression, found `+`
   --> $DIR/expr-as-stmt.rs:8:9
    |
 LL |     {2} + {2}
-   |         ^ unexpected `+`
+   |         ^ expected expression
    |
 help: parentheses are required to parse this as an expression
    |
@@ -20,11 +20,11 @@ help: parentheses are required to parse this as an expression
 LL |     ({2}) + 2
    |     +   +
 
-error: leading `+` is not supported
+error: expected expression, found `+`
   --> $DIR/expr-as-stmt.rs:19:12
    |
 LL |     { 42 } + foo;
-   |            ^ unexpected `+`
+   |            ^ expected expression
    |
 help: parentheses are required to parse this as an expression
    |
diff --git a/src/test/ui/parser/issue-88276-unary-plus.fixed b/src/test/ui/parser/issue-88276-unary-plus.fixed
index 279cdb5060a..25b7c340f60 100644
--- a/src/test/ui/parser/issue-88276-unary-plus.fixed
+++ b/src/test/ui/parser/issue-88276-unary-plus.fixed
@@ -2,12 +2,7 @@
 #[allow(unused_parens)]
 fn main() {
     let _ = 1; //~ ERROR leading `+` is not supported
-    let _ = -(1+2)*3; //~ ERROR leading `+` is not supported
-    let _ = --(1+2)*3; //~ ERROR leading `+` is not supported
-                         //~| ERROR leading `+` is not supported
-    let _ = (1 + 2) * 3; //~ ERROR leading `+` is not supported
+    let _ = (1.0 + 2.0) * 3.0; //~ ERROR leading `+` is not supported
                            //~| ERROR leading `+` is not supported
-    let _ = (&"hello"); //~ ERROR leading `+` is not supported
     let _ = [3, 4+6]; //~ ERROR leading `+` is not supported
-                        //~| ERROR leading `+` is not supported
 }
diff --git a/src/test/ui/parser/issue-88276-unary-plus.rs b/src/test/ui/parser/issue-88276-unary-plus.rs
index a72dad4dc71..11b2e9d6016 100644
--- a/src/test/ui/parser/issue-88276-unary-plus.rs
+++ b/src/test/ui/parser/issue-88276-unary-plus.rs
@@ -2,12 +2,7 @@
 #[allow(unused_parens)]
 fn main() {
     let _ = +1; //~ ERROR leading `+` is not supported
-    let _ = -+(1+2)*3; //~ ERROR leading `+` is not supported
-    let _ = -+-+(1+2)*3; //~ ERROR leading `+` is not supported
-                         //~| ERROR leading `+` is not supported
-    let _ = (1 + +2) * +3; //~ ERROR leading `+` is not supported
+    let _ = (1.0 + +2.0) * +3.0; //~ ERROR leading `+` is not supported
                            //~| ERROR leading `+` is not supported
-    let _ = (+&"hello"); //~ ERROR leading `+` is not supported
-    let _ = +[+3, 4+6]; //~ ERROR leading `+` is not supported
-                        //~| ERROR leading `+` is not supported
+    let _ = [+3, 4+6]; //~ ERROR leading `+` is not supported
 }
diff --git a/src/test/ui/parser/issue-88276-unary-plus.stderr b/src/test/ui/parser/issue-88276-unary-plus.stderr
index 255839bc684..b26761729a8 100644
--- a/src/test/ui/parser/issue-88276-unary-plus.stderr
+++ b/src/test/ui/parser/issue-88276-unary-plus.stderr
@@ -2,82 +2,49 @@ error: leading `+` is not supported
   --> $DIR/issue-88276-unary-plus.rs:4:13
    |
 LL |     let _ = +1;
-   |             ^
-   |             |
-   |             unexpected `+`
-   |             help: try removing the `+`
-
-error: leading `+` is not supported
-  --> $DIR/issue-88276-unary-plus.rs:5:14
+   |             ^ unexpected `+`
    |
-LL |     let _ = -+(1+2)*3;
-   |              ^
-   |              |
-   |              unexpected `+`
-   |              help: try removing the `+`
-
-error: leading `+` is not supported
-  --> $DIR/issue-88276-unary-plus.rs:6:14
+help: try removing the `+`
    |
-LL |     let _ = -+-+(1+2)*3;
-   |              ^
-   |              |
-   |              unexpected `+`
-   |              help: try removing the `+`
+LL -     let _ = +1;
+LL +     let _ = 1;
+   | 
 
 error: leading `+` is not supported
-  --> $DIR/issue-88276-unary-plus.rs:6:16
+  --> $DIR/issue-88276-unary-plus.rs:5:20
    |
-LL |     let _ = -+-+(1+2)*3;
-   |                ^
-   |                |
-   |                unexpected `+`
-   |                help: try removing the `+`
-
-error: leading `+` is not supported
-  --> $DIR/issue-88276-unary-plus.rs:8:18
+LL |     let _ = (1.0 + +2.0) * +3.0;
+   |                    ^ unexpected `+`
    |
-LL |     let _ = (1 + +2) * +3;
-   |                  ^
-   |                  |
-   |                  unexpected `+`
-   |                  help: try removing the `+`
-
-error: leading `+` is not supported
-  --> $DIR/issue-88276-unary-plus.rs:8:24
+help: try removing the `+`
    |
-LL |     let _ = (1 + +2) * +3;
-   |                        ^
-   |                        |
-   |                        unexpected `+`
-   |                        help: try removing the `+`
+LL -     let _ = (1.0 + +2.0) * +3.0;
+LL +     let _ = (1.0 + 2.0) * +3.0;
+   | 
 
 error: leading `+` is not supported
-  --> $DIR/issue-88276-unary-plus.rs:10:14
+  --> $DIR/issue-88276-unary-plus.rs:5:28
    |
-LL |     let _ = (+&"hello");
-   |              ^
-   |              |
-   |              unexpected `+`
-   |              help: try removing the `+`
-
-error: leading `+` is not supported
-  --> $DIR/issue-88276-unary-plus.rs:11:13
+LL |     let _ = (1.0 + +2.0) * +3.0;
+   |                            ^ unexpected `+`
    |
-LL |     let _ = +[+3, 4+6];
-   |             ^
-   |             |
-   |             unexpected `+`
-   |             help: try removing the `+`
+help: try removing the `+`
+   |
+LL -     let _ = (1.0 + +2.0) * +3.0;
+LL +     let _ = (1.0 + +2.0) * 3.0;
+   | 
 
 error: leading `+` is not supported
-  --> $DIR/issue-88276-unary-plus.rs:11:15
+  --> $DIR/issue-88276-unary-plus.rs:7:14
+   |
+LL |     let _ = [+3, 4+6];
+   |              ^ unexpected `+`
+   |
+help: try removing the `+`
    |
-LL |     let _ = +[+3, 4+6];
-   |               ^
-   |               |
-   |               unexpected `+`
-   |               help: try removing the `+`
+LL -     let _ = [+3, 4+6];
+LL +     let _ = [3, 4+6];
+   | 
 
-error: aborting due to 9 previous errors
+error: aborting due to 4 previous errors