From b2bdc37a558e4686e9e1c4eb5d967bdc69485826 Mon Sep 17 00:00:00 2001 From: Centri3 <114838443+Centri3@users.noreply.github.com> Date: Sun, 11 Jun 2023 04:55:02 -0500 Subject: [PATCH] add description add description --- clippy_lints/src/needless_if.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/clippy_lints/src/needless_if.rs b/clippy_lints/src/needless_if.rs index 1568c3533a0..8e27d3a4009 100644 --- a/clippy_lints/src/needless_if.rs +++ b/clippy_lints/src/needless_if.rs @@ -7,16 +7,24 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { /// ### What it does + /// Checks for empty `if` statements with no else branch. /// /// ### Why is this bad? + /// It can be entirely omitted, and often the condition too. + /// + /// ### Known issues + /// This will 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 - /// ```rust - /// // example code where clippy issues a warning + /// ```rust,ignore + /// if really_expensive_condition(&i) {} + /// if really_expensive_condition_with_side_effects(&mut i) {} /// ``` /// Use instead: - /// ```rust - /// // example code which does not raise clippy warning + /// ```rust,ignore + /// // + /// really_expensive_condition_with_side_effects(&mut i); /// ``` #[clippy::version = "1.72.0"] pub NEEDLESS_IF,