diff options
| author | Theodore Luo Wang <wangtheo662@gmail.com> | 2021-09-01 11:54:06 -0400 |
|---|---|---|
| committer | Theodore Luo Wang <wangtheo662@gmail.com> | 2021-09-01 11:54:06 -0400 |
| commit | 5a863d594c725d09ab8f0df5caba374d72200976 (patch) | |
| tree | d28a9a6e49f245fe04115c05df353464723e0912 /src/test/ui/parser | |
| parent | e7fb98e7258557034f0d0caf81a53b0070a87297 (diff) | |
| download | rust-5a863d594c725d09ab8f0df5caba374d72200976.tar.gz rust-5a863d594c725d09ab8f0df5caba374d72200976.zip | |
Add checks for a block before a unary plus. Fix failing tests
Diffstat (limited to 'src/test/ui/parser')
| -rw-r--r-- | src/test/ui/parser/expr-as-stmt.fixed | 6 | ||||
| -rw-r--r-- | src/test/ui/parser/expr-as-stmt.rs | 6 | ||||
| -rw-r--r-- | src/test/ui/parser/expr-as-stmt.stderr | 12 | ||||
| -rw-r--r-- | src/test/ui/parser/issue-88276-unary-plus.fixed | 13 | ||||
| -rw-r--r-- | src/test/ui/parser/issue-88276-unary-plus.rs | 13 | ||||
| -rw-r--r-- | src/test/ui/parser/issue-88276-unary-plus.stderr | 83 |
6 files changed, 121 insertions, 12 deletions
diff --git a/src/test/ui/parser/expr-as-stmt.fixed b/src/test/ui/parser/expr-as-stmt.fixed index c217ab9774f..79d73090a04 100644 --- a/src/test/ui/parser/expr-as-stmt.fixed +++ b/src/test/ui/parser/expr-as-stmt.fixed @@ -5,18 +5,18 @@ #![allow(unused_must_use)] fn foo() -> i32 { - ({2}) + {2} //~ ERROR expected expression, found `+` + ({2}) + {2} //~ ERROR leading `+` is not supported //~^ ERROR mismatched types } fn bar() -> i32 { - ({2}) + 2 //~ ERROR expected expression, found `+` + ({2}) + 2 //~ ERROR leading `+` is not supported //~^ ERROR mismatched types } fn zul() -> u32 { let foo = 3; - ({ 42 }) + foo; //~ ERROR expected expression, found `+` + ({ 42 }) + foo; //~ ERROR leading `+` is not supported //~^ 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 b04025faaec..8698f99b81a 100644 --- a/src/test/ui/parser/expr-as-stmt.rs +++ b/src/test/ui/parser/expr-as-stmt.rs @@ -5,18 +5,18 @@ #![allow(unused_must_use)] fn foo() -> i32 { - {2} + {2} //~ ERROR expected expression, found `+` + {2} + {2} //~ ERROR leading `+` is not supported //~^ ERROR mismatched types } fn bar() -> i32 { - {2} + 2 //~ ERROR expected expression, found `+` + {2} + 2 //~ ERROR leading `+` is not supported //~^ ERROR mismatched types } fn zul() -> u32 { let foo = 3; - { 42 } + foo; //~ ERROR expected expression, found `+` + { 42 } + foo; //~ ERROR leading `+` is not supported //~^ 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 ba5cd01abfc..91f97c4662a 100644 --- a/src/test/ui/parser/expr-as-stmt.stderr +++ b/src/test/ui/parser/expr-as-stmt.stderr @@ -1,30 +1,30 @@ -error: expected expression, found `+` +error: leading `+` is not supported --> $DIR/expr-as-stmt.rs:8:9 | LL | {2} + {2} - | ^ expected expression + | ^ unexpected `+` | help: parentheses are required to parse this as an expression | LL | ({2}) + {2} | + + -error: expected expression, found `+` +error: leading `+` is not supported --> $DIR/expr-as-stmt.rs:13:9 | LL | {2} + 2 - | ^ expected expression + | ^ unexpected `+` | help: parentheses are required to parse this as an expression | LL | ({2}) + 2 | + + -error: expected expression, found `+` +error: leading `+` is not supported --> $DIR/expr-as-stmt.rs:19:12 | LL | { 42 } + foo; - | ^ expected expression + | ^ unexpected `+` | 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 new file mode 100644 index 00000000000..279cdb5060a --- /dev/null +++ b/src/test/ui/parser/issue-88276-unary-plus.fixed @@ -0,0 +1,13 @@ +// run-rustfix +#[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 + //~| 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 new file mode 100644 index 00000000000..a72dad4dc71 --- /dev/null +++ b/src/test/ui/parser/issue-88276-unary-plus.rs @@ -0,0 +1,13 @@ +// run-rustfix +#[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 + //~| 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.stderr b/src/test/ui/parser/issue-88276-unary-plus.stderr new file mode 100644 index 00000000000..255839bc684 --- /dev/null +++ b/src/test/ui/parser/issue-88276-unary-plus.stderr @@ -0,0 +1,83 @@ +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 + | +LL | let _ = -+(1+2)*3; + | ^ + | | + | unexpected `+` + | help: try removing the `+` + +error: leading `+` is not supported + --> $DIR/issue-88276-unary-plus.rs:6:14 + | +LL | let _ = -+-+(1+2)*3; + | ^ + | | + | unexpected `+` + | help: try removing the `+` + +error: leading `+` is not supported + --> $DIR/issue-88276-unary-plus.rs:6:16 + | +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 + +2) * +3; + | ^ + | | + | unexpected `+` + | help: try removing the `+` + +error: leading `+` is not supported + --> $DIR/issue-88276-unary-plus.rs:8:24 + | +LL | let _ = (1 + +2) * +3; + | ^ + | | + | unexpected `+` + | help: try removing the `+` + +error: leading `+` is not supported + --> $DIR/issue-88276-unary-plus.rs:10:14 + | +LL | let _ = (+&"hello"); + | ^ + | | + | unexpected `+` + | help: try removing the `+` + +error: leading `+` is not supported + --> $DIR/issue-88276-unary-plus.rs:11:13 + | +LL | let _ = +[+3, 4+6]; + | ^ + | | + | unexpected `+` + | help: try removing the `+` + +error: leading `+` is not supported + --> $DIR/issue-88276-unary-plus.rs:11:15 + | +LL | let _ = +[+3, 4+6]; + | ^ + | | + | unexpected `+` + | help: try removing the `+` + +error: aborting due to 9 previous errors + |
