RS.CLIPPY.NEEDLESS_IF
Checks for empty if branches
This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: needless_if. Copyright ©2025 The Rust Team. All rights reserved.
What it does
Checks for empty if branches with no else branch.
Why is this bad?
It can be entirely omitted, and often the condition too.
Known issues
This will usually only suggest to remove the if statement, not the condition. Other lints
such as no_effect will take care of removing the condition if it's unnecessary.
Example
if really_expensive_condition(&i) {}
if really_expensive_condition_with_side_effects(&mut i) {}
Use instead:
// <omitted>
really_expensive_condition_with_side_effects(&mut i);