RS.CLIPPY.SUSPICIOUS_OPERATION_GROUPINGS

Groupings of binary operations that look suspiciously like typos

This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: suspicious_operation_groupings. Copyright ©2025 The Rust Team. All rights reserved.

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
    }
}