Both operands of an operation are the same expression
ID |
rust.correctness.identical_operands |
Severity |
low |
Remediation Complexity |
trivial |
Remediation Risk |
low |
Remediation Effort |
low |
Resource |
Suspicious Construct |
Language |
Rust |
Description
Both sides of this operation are the same expression, so the result is a constant and the operand is never really examined. One side was almost certainly meant to name something else.
Rationale
Both sides of this operation are the same expression, so the result is a constant and the operand is never really examined. One side was almost certainly meant to name something else.
The following code illustrates the pattern detected by this rule:
fn compare(left: i32, right: i32) -> bool {
// FLAGGED: Both operands of an operation are the same expression
left == left
}