Skip to content

Commit 0b9c589

Browse files
committed
adjust assignment-in-if test accordingly.
1 parent 05d59fe commit 0b9c589

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

src/test/ui/type/type-check/assignment-in-if.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,13 @@ fn main() {
3131
//~^ ERROR mismatched types
3232
println!("{}", x);
3333
}
34-
if (if true { x = 4 } else { x = 5 }) {
35-
//~^ ERROR mismatched types
34+
if (
35+
if true {
36+
x = 4 //~ ERROR mismatched types
37+
} else {
38+
x = 5 //~ ERROR mismatched types
39+
}
40+
) {
3641
println!("{}", x);
3742
}
3843
}

src/test/ui/type/type-check/assignment-in-if.stderr

+19-4
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,29 @@ LL | if 3 = x {
4747
found type `()`
4848

4949
error[E0308]: mismatched types
50-
--> $DIR/assignment-in-if.rs:34:8
50+
--> $DIR/assignment-in-if.rs:36:13
5151
|
52-
LL | if (if true { x = 4 } else { x = 5 }) {
53-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected bool, found ()
52+
LL | x = 4
53+
| ^^^^^
54+
| |
55+
| expected bool, found ()
56+
| help: try comparing for equality: `x == 4`
5457
|
5558
= note: expected type `bool`
5659
found type `()`
5760

58-
error: aborting due to 5 previous errors
61+
error[E0308]: mismatched types
62+
--> $DIR/assignment-in-if.rs:38:13
63+
|
64+
LL | x = 5
65+
| ^^^^^
66+
| |
67+
| expected bool, found ()
68+
| help: try comparing for equality: `x == 5`
69+
|
70+
= note: expected type `bool`
71+
found type `()`
72+
73+
error: aborting due to 6 previous errors
5974

6075
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)