Skip to content

Commit 79919a7

Browse files
committed
Add "while" tests for issue 54109
1 parent acc44e4 commit 79919a7

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

src/test/ui/did_you_mean/issue-54109-and_instead_of_ampersands.rs

+18
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,23 @@ fn test_or_par() {
4444
}
4545
}
4646

47+
fn test_while_and() {
48+
let a = true;
49+
let b = false;
50+
while a and b {
51+
//~^ ERROR expected one of `!`, `.`, `::`, `?`, `{`, or an operator, found `and`
52+
println!("both");
53+
}
54+
}
55+
56+
fn test_while_or() {
57+
let a = true;
58+
let b = false;
59+
while a or b {
60+
//~^ ERROR expected one of `!`, `.`, `::`, `?`, `{`, or an operator, found `or`
61+
println!("both");
62+
}
63+
}
64+
4765
fn main() {
4866
}

src/test/ui/did_you_mean/issue-54109-and_instead_of_ampersands.stderr

+20-1
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,23 @@ LL | if (a or b) {
3232
| expected one of 8 possible tokens here
3333
| help: use `||` instead of `or` for the boolean operator: `||`
3434

35-
error: aborting due to 4 previous errors
35+
error: expected one of `!`, `.`, `::`, `?`, `{`, or an operator, found `and`
36+
--> $DIR/issue-54109-and_instead_of_ampersands.rs:50:13
37+
|
38+
LL | while a and b {
39+
| ^^^
40+
| |
41+
| expected one of `!`, `.`, `::`, `?`, `{`, or an operator here
42+
| help: use `&&` instead of `and` for the boolean operator: `&&`
43+
44+
error: expected one of `!`, `.`, `::`, `?`, `{`, or an operator, found `or`
45+
--> $DIR/issue-54109-and_instead_of_ampersands.rs:59:13
46+
|
47+
LL | while a or b {
48+
| ^^
49+
| |
50+
| expected one of `!`, `.`, `::`, `?`, `{`, or an operator here
51+
| help: use `||` instead of `or` for the boolean operator: `||`
52+
53+
error: aborting due to 6 previous errors
54+

0 commit comments

Comments
 (0)