Skip to content

Commit 00558d5

Browse files
committed
add description
1 parent 7ba9042 commit 00558d5

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

clippy_lints/src/needless_if.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,24 @@ use rustc_session::{declare_lint_pass, declare_tool_lint};
77

88
declare_clippy_lint! {
99
/// ### What it does
10+
/// Checks for empty `if` statement with no else branch.
1011
///
1112
/// ### Why is this bad?
13+
/// It can be entirely omitted, and often the condition too.
14+
///
15+
/// ### Known issues
16+
/// This will only suggest to remove the `if` statement, not the condition. Other lints such as
17+
/// `no_effect` will take care of removing the condition if it's unnecessary.
1218
///
1319
/// ### Example
1420
/// ```rust
15-
/// // example code where clippy issues a warning
21+
/// if really_expensive_condition(&i) {}
22+
/// if really_expensive_condition_with_side_effects(&mut i) {}
1623
/// ```
1724
/// Use instead:
1825
/// ```rust
19-
/// // example code which does not raise clippy warning
26+
/// // <omitted>
27+
/// really_expensive_condition_with_side_effects(&mut i);
2028
/// ```
2129
#[clippy::version = "1.72.0"]
2230
pub NEEDLESS_IF,

0 commit comments

Comments
 (0)