Skip to content

Commit b2bdc37

Browse files
committed
add description
add description
1 parent 7ba9042 commit b2bdc37

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

clippy_lints/src/needless_if.rs

Lines changed: 12 additions & 4 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` statements 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
14-
/// ```rust
15-
/// // example code where clippy issues a warning
20+
/// ```rust,ignore
21+
/// if really_expensive_condition(&i) {}
22+
/// if really_expensive_condition_with_side_effects(&mut i) {}
1623
/// ```
1724
/// Use instead:
18-
/// ```rust
19-
/// // example code which does not raise clippy warning
25+
/// ```rust,ignore
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)