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};
7
7
8
8
declare_clippy_lint ! {
9
9
/// ### What it does
10
+ /// Checks for empty `if` statements with no else branch.
10
11
///
11
12
/// ### 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.
12
18
///
13
19
/// ### 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) {}
16
23
/// ```
17
24
/// 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);
20
28
/// ```
21
29
#[ clippy:: version = "1.72.0" ]
22
30
pub NEEDLESS_IF ,
You can’t perform that action at this time.
0 commit comments