RS.CLIPPY.IFS_SAME_COND

Consecutive `if`s with the same condition

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

What it does

Checks for consecutive ifs with the same condition.

Why is this bad?

This is probably a copy & paste error.

Example

if a == b {
    ...
} else if a == b {
    ...
}

Note that this lint ignores all conditions with a function call as it could have side effects:

if foo() {
    ...
} else if foo() { // not linted
    ...
}

Configuration

  • ignore-interior-mutability: A list of paths to types that should be treated as if they do not contain interior mutability

    (default: ["bytes::Bytes"])