blob: 81ede5d3da575271f8fd5569d6f8c262c4887700 (
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
|
### What it does
Checks for unlikely usages of binary operators that are almost
certainly typos and/or copy/paste errors, given the other usages
of binary operators nearby.
### Why is this bad?
They are probably bugs and if they aren't then they look like bugs
and you should add a comment explaining why you are doing such an
odd set of operations.
### Known problems
There may be some false positives if you are trying to do something
unusual that happens to look like a typo.
### Example
```
struct Vec3 {
x: f64,
y: f64,
z: f64,
}
impl Eq for Vec3 {}
impl PartialEq for Vec3 {
fn eq(&self, other: &Self) -> bool {
// This should trigger the lint because `self.x` is compared to `other.y`
self.x == other.y && self.y == other.y && self.z == other.z
}
}
```
Use instead:
```
// same as above except:
impl PartialEq for Vec3 {
fn eq(&self, other: &Self) -> bool {
// Note we now compare other.x to self.x
self.x == other.x && self.y == other.y && self.z == other.z
}
}
```
|