Skip to content

Commit 68eba9a

Browse files
committed
Make sure while-exprs require 'cond: bool' exactly.
1 parent d9f1dc8 commit 68eba9a

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

src/test/ui/if/if-no-match-bindings.rs

+6
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,10 @@ fn main() {
1919
if b_mut_ref() {} //~ ERROR mismatched types [E0308]
2020
if &true {} //~ ERROR mismatched types [E0308]
2121
if &mut true {} //~ ERROR mismatched types [E0308]
22+
23+
// This is also NOT:
24+
while b_ref() {} //~ ERROR mismatched types [E0308]
25+
while b_mut_ref() {} //~ ERROR mismatched types [E0308]
26+
while &true {} //~ ERROR mismatched types [E0308]
27+
while &mut true {} //~ ERROR mismatched types [E0308]
2228
}

src/test/ui/if/if-no-match-bindings.stderr

+37-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,42 @@ LL | if &mut true {}
3434
= note: expected type `bool`
3535
found type `&mut bool`
3636

37-
error: aborting due to 4 previous errors
37+
error[E0308]: mismatched types
38+
--> $DIR/if-no-match-bindings.rs:24:11
39+
|
40+
LL | while b_ref() {}
41+
| ^^^^^^^ expected bool, found &bool
42+
|
43+
= note: expected type `bool`
44+
found type `&bool`
45+
46+
error[E0308]: mismatched types
47+
--> $DIR/if-no-match-bindings.rs:25:11
48+
|
49+
LL | while b_mut_ref() {}
50+
| ^^^^^^^^^^^ expected bool, found &mut bool
51+
|
52+
= note: expected type `bool`
53+
found type `&mut bool`
54+
55+
error[E0308]: mismatched types
56+
--> $DIR/if-no-match-bindings.rs:26:11
57+
|
58+
LL | while &true {}
59+
| ^^^^^ expected bool, found &bool
60+
|
61+
= note: expected type `bool`
62+
found type `&bool`
63+
64+
error[E0308]: mismatched types
65+
--> $DIR/if-no-match-bindings.rs:27:11
66+
|
67+
LL | while &mut true {}
68+
| ^^^^^^^^^ expected bool, found &mut bool
69+
|
70+
= note: expected type `bool`
71+
found type `&mut bool`
72+
73+
error: aborting due to 8 previous errors
3874

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

0 commit comments

Comments
 (0)