File tree 2 files changed +26
-6
lines changed
src/test/ui/type/type-check
2 files changed +26
-6
lines changed Original file line number Diff line number Diff line change @@ -31,8 +31,13 @@ fn main() {
31
31
//~^ ERROR mismatched types
32
32
println ! ( "{}" , x) ;
33
33
}
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
+ ) {
36
41
println ! ( "{}" , x) ;
37
42
}
38
43
}
Original file line number Diff line number Diff line change @@ -47,14 +47,29 @@ LL | if 3 = x {
47
47
found type `()`
48
48
49
49
error[E0308]: mismatched types
50
- --> $DIR/assignment-in-if.rs:34:8
50
+ --> $DIR/assignment-in-if.rs:36:13
51
51
|
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`
54
57
|
55
58
= note: expected type `bool`
56
59
found type `()`
57
60
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
59
74
60
75
For more information about this error, try `rustc --explain E0308`.
You can’t perform that action at this time.
0 commit comments