Skip to content

Commit 888b8c9

Browse files
committed
Add tests for issue 54109
1 parent 636f518 commit 888b8c9

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn test_and() {
12+
let a = true;
13+
let b = false;
14+
if a and b {
15+
//~^ ERROR expected `{`, found `and`
16+
println!("both");
17+
}
18+
}
19+
20+
fn test_or() {
21+
let a = true;
22+
let b = false;
23+
if a or b {
24+
//~^ ERROR expected `{`, found `or`
25+
println!("both");
26+
}
27+
}
28+
29+
fn test_and_par() {
30+
let a = true;
31+
let b = false;
32+
if (a and b) {
33+
//~^ ERROR expected one of `!`, `)`, `,`, `.`, `::`, `?`, `{`, or an operator, found `and`
34+
println!("both");
35+
}
36+
}
37+
38+
fn test_or_par() {
39+
let a = true;
40+
let b = false;
41+
if (a or b) {
42+
//~^ ERROR expected one of `!`, `)`, `,`, `.`, `::`, `?`, `{`, or an operator, found `or`
43+
println!("both");
44+
}
45+
}
46+
47+
fn main() {
48+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
error: expected `{`, found `and`
2+
--> $DIR/issue-54109-and_instead_of_ampersands.rs:14:10
3+
|
4+
LL | if a and b {
5+
| -- ^^^
6+
| |
7+
| this `if` statement has a condition, but no block
8+
|
9+
= help: Use `&&` instead of `and` for the boolean operator
10+
11+
error: expected `{`, found `or`
12+
--> $DIR/issue-54109-and_instead_of_ampersands.rs:23:10
13+
|
14+
LL | if a or b {
15+
| -- ^^
16+
| |
17+
| this `if` statement has a condition, but no block
18+
|
19+
= help: Use `||` instead of `or` for the boolean operator
20+
21+
error: expected one of `!`, `)`, `,`, `.`, `::`, `?`, `{`, or an operator, found `and`
22+
--> $DIR/issue-54109-and_instead_of_ampersands.rs:32:11
23+
|
24+
LL | if (a and b) {
25+
| ^^^ expected one of 8 possible tokens here
26+
|
27+
= help: Use `&&` instead of `and` for the boolean operator
28+
29+
error: expected one of `!`, `)`, `,`, `.`, `::`, `?`, `{`, or an operator, found `or`
30+
--> $DIR/issue-54109-and_instead_of_ampersands.rs:41:11
31+
|
32+
LL | if (a or b) {
33+
| ^^ expected one of 8 possible tokens here
34+
|
35+
= help: Use `||` instead of `or` for the boolean operator
36+
37+
error: aborting due to 4 previous errors
38+

0 commit comments

Comments
 (0)