suggest parenthesis around ExprWithBlock BinOp ExprWithBlock
This commit is contained in:
parent
4bb15759d7
commit
35c00a9731
5 changed files with 71 additions and 14 deletions
|
|
@ -64,4 +64,16 @@ fn asteroids() -> impl FnOnce() -> bool {
|
|||
{ foo(); } || { true } //~ ERROR E0308
|
||||
}
|
||||
|
||||
// https://github.com/rust-lang/rust/issues/105179
|
||||
fn r#match() -> i32 {
|
||||
(match () { () => 1 }) + match () { () => 1 } //~ ERROR expected expression, found `+`
|
||||
//~^ ERROR mismatched types
|
||||
}
|
||||
|
||||
// https://github.com/rust-lang/rust/issues/102171
|
||||
fn r#unsafe() -> i32 {
|
||||
(unsafe { 1 }) + unsafe { 1 } //~ ERROR expected expression, found `+`
|
||||
//~^ ERROR mismatched types
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -64,4 +64,16 @@ fn asteroids() -> impl FnOnce() -> bool {
|
|||
{ foo() } || { true } //~ ERROR E0308
|
||||
}
|
||||
|
||||
// https://github.com/rust-lang/rust/issues/105179
|
||||
fn r#match() -> i32 {
|
||||
match () { () => 1 } + match () { () => 1 } //~ ERROR expected expression, found `+`
|
||||
//~^ ERROR mismatched types
|
||||
}
|
||||
|
||||
// https://github.com/rust-lang/rust/issues/102171
|
||||
fn r#unsafe() -> i32 {
|
||||
unsafe { 1 } + unsafe { 1 } //~ ERROR expected expression, found `+`
|
||||
//~^ ERROR mismatched types
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -55,6 +55,28 @@ help: parentheses are required to parse this as an expression
|
|||
LL | ({ true }) | { true }
|
||||
| + +
|
||||
|
||||
error: expected expression, found `+`
|
||||
--> $DIR/expr-as-stmt.rs:69:26
|
||||
|
|
||||
LL | match () { () => 1 } + match () { () => 1 }
|
||||
| ^ expected expression
|
||||
|
|
||||
help: parentheses are required to parse this as an expression
|
||||
|
|
||||
LL | (match () { () => 1 }) + match () { () => 1 }
|
||||
| + +
|
||||
|
||||
error: expected expression, found `+`
|
||||
--> $DIR/expr-as-stmt.rs:75:18
|
||||
|
|
||||
LL | unsafe { 1 } + unsafe { 1 }
|
||||
| ^ expected expression
|
||||
|
|
||||
help: parentheses are required to parse this as an expression
|
||||
|
|
||||
LL | (unsafe { 1 }) + unsafe { 1 }
|
||||
| + +
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/expr-as-stmt.rs:64:7
|
||||
|
|
||||
|
|
@ -201,7 +223,26 @@ help: parentheses are required to parse this as an expression
|
|||
LL | ({ true }) || { true }
|
||||
| + +
|
||||
|
||||
error: aborting due to 18 previous errors
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/expr-as-stmt.rs:69:5
|
||||
|
|
||||
LL | match () { () => 1 } + match () { () => 1 }
|
||||
| ^^^^^^^^^^^^^^^^^^^^- help: consider using a semicolon here
|
||||
| |
|
||||
| expected `()`, found integer
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/expr-as-stmt.rs:75:14
|
||||
|
|
||||
LL | unsafe { 1 } + unsafe { 1 }
|
||||
| ^ expected `()`, found integer
|
||||
|
|
||||
help: you might have meant to return this value
|
||||
|
|
||||
LL | unsafe { return 1; } + unsafe { 1 }
|
||||
| ++++++ +
|
||||
|
||||
error: aborting due to 22 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0308, E0600, E0614.
|
||||
For more information about an error, try `rustc --explain E0308`.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue