File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -7,16 +7,24 @@ use rustc_session::{declare_lint_pass, declare_tool_lint};
77
88declare_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 ,
You can’t perform that action at this time.
0 commit comments