adjust assignment-in-if test accordingly.

This commit is contained in:
Mazdak Farrokhzad 2019-03-26 14:57:17 +01:00
parent 05d59feb64
commit 0b9c589beb
2 changed files with 26 additions and 6 deletions

View File

@ -31,8 +31,13 @@ fn main() {
//~^ ERROR mismatched types
println!("{}", x);
}
if (if true { x = 4 } else { x = 5 }) {
//~^ ERROR mismatched types
if (
if true {
x = 4 //~ ERROR mismatched types
} else {
x = 5 //~ ERROR mismatched types
}
) {
println!("{}", x);
}
}

View File

@ -47,14 +47,29 @@ LL | if 3 = x {
found type `()`
error[E0308]: mismatched types
--> $DIR/assignment-in-if.rs:34:8
--> $DIR/assignment-in-if.rs:36:13
|
LL | if (if true { x = 4 } else { x = 5 }) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected bool, found ()
LL | x = 4
| ^^^^^
| |
| expected bool, found ()
| help: try comparing for equality: `x == 4`
|
= note: expected type `bool`
found type `()`
error: aborting due to 5 previous errors
error[E0308]: mismatched types
--> $DIR/assignment-in-if.rs:38:13
|
LL | x = 5
| ^^^^^
| |
| expected bool, found ()
| help: try comparing for equality: `x == 5`
|
= note: expected type `bool`
found type `()`
error: aborting due to 6 previous errors
For more information about this error, try `rustc --explain E0308`.