blob: 4275ae64fdd65bf7ddfad9d33c8f64e03943dff6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
#![warn(clippy::short_circuit_statement)]
#![allow(clippy::nonminimal_bool)]
fn main() {
f() && g();
//~^ short_circuit_statement
f() || g();
//~^ short_circuit_statement
1 == 2 || g();
//~^ short_circuit_statement
(f() || g()) && (H * 2);
//~^ short_circuit_statement
(f() || g()) || (H * 2);
//~^ short_circuit_statement
macro_rules! mac {
($f:ident or $g:ident) => {
$f() || $g()
};
($f:ident and $g:ident) => {
$f() && $g()
};
() => {
f() && g()
};
}
mac!() && mac!();
//~^ short_circuit_statement
mac!() || mac!();
//~^ short_circuit_statement
// Do not lint if the expression comes from a macro
mac!();
}
fn f() -> bool {
true
}
fn g() -> bool {
false
}
struct H;
impl std::ops::Mul<u32> for H {
type Output = bool;
fn mul(self, other: u32) -> Self::Output {
true
}
}
|