Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6584,6 +6584,7 @@ Released 2018-09-13
[`needless_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_else
[`needless_for_each`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_for_each
[`needless_if`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_if
[`needless_ifs`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_ifs
[`needless_late_init`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_late_init
[`needless_lifetimes`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes
[`needless_match`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_match
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/declared_lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ pub static LINTS: &[&::declare_clippy_lint::LintInfo] = &[
crate::needless_continue::NEEDLESS_CONTINUE_INFO,
crate::needless_else::NEEDLESS_ELSE_INFO,
crate::needless_for_each::NEEDLESS_FOR_EACH_INFO,
crate::needless_if::NEEDLESS_IF_INFO,
crate::needless_ifs::NEEDLESS_IFS_INFO,
crate::needless_late_init::NEEDLESS_LATE_INIT_INFO,
crate::needless_maybe_sized::NEEDLESS_MAYBE_SIZED_INFO,
crate::needless_parens_on_range_literals::NEEDLESS_PARENS_ON_RANGE_LITERALS_INFO,
Expand Down
2 changes: 2 additions & 0 deletions clippy_lints/src/deprecated_lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ declare_with_version! { RENAMED(RENAMED_VERSION) = [
("clippy::mem_discriminant_non_enum", "enum_intrinsics_non_enums"),
#[clippy::version = "1.80.0"]
("clippy::mismatched_target_os", "unexpected_cfgs"),
#[clippy::version = "1.92.0"]
("clippy::needless_if", "clippy::needless_ifs"),
#[clippy::version = ""]
("clippy::new_without_default_derive", "clippy::new_without_default"),
#[clippy::version = ""]
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ mod needless_borrows_for_generic_args;
mod needless_continue;
mod needless_else;
mod needless_for_each;
mod needless_if;
mod needless_ifs;
mod needless_late_init;
mod needless_maybe_sized;
mod needless_parens_on_range_literals;
Expand Down Expand Up @@ -752,7 +752,7 @@ pub fn register_lint_passes(store: &mut rustc_lint::LintStore, conf: &'static Co
store.register_late_pass(|_| Box::new(endian_bytes::EndianBytes));
store.register_late_pass(|_| Box::new(redundant_type_annotations::RedundantTypeAnnotations));
store.register_late_pass(|_| Box::new(arc_with_non_send_sync::ArcWithNonSendSync));
store.register_late_pass(|_| Box::new(needless_if::NeedlessIf));
store.register_late_pass(|_| Box::new(needless_ifs::NeedlessIfs));
store.register_late_pass(move |_| Box::new(min_ident_chars::MinIdentChars::new(conf)));
store.register_late_pass(move |_| Box::new(large_stack_frames::LargeStackFrames::new(conf)));
store.register_late_pass(|_| Box::new(single_range_in_vec_init::SingleRangeInVecInit));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ declare_clippy_lint! {
/// really_expensive_condition_with_side_effects(&mut i);
/// ```
#[clippy::version = "1.72.0"]
pub NEEDLESS_IF,
pub NEEDLESS_IFS,
complexity,
"checks for empty if branches"
}
declare_lint_pass!(NeedlessIf => [NEEDLESS_IF]);
declare_lint_pass!(NeedlessIfs => [NEEDLESS_IFS]);

impl LateLintPass<'_> for NeedlessIf {
impl LateLintPass<'_> for NeedlessIfs {
fn check_stmt<'tcx>(&mut self, cx: &LateContext<'tcx>, stmt: &Stmt<'tcx>) {
if let StmtKind::Expr(expr) = stmt.kind
&& let Some(If {
Expand All @@ -62,7 +62,7 @@ impl LateLintPass<'_> for NeedlessIf {
{
span_lint_and_sugg(
cx,
NEEDLESS_IF,
NEEDLESS_IFS,
stmt.span,
"this `if` branch is empty",
"you can remove it",
Expand Down
2 changes: 1 addition & 1 deletion tests/ui-toml/excessive_nesting/excessive_nesting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
clippy::no_effect,
clippy::unnecessary_operation,
clippy::never_loop,
clippy::needless_if,
clippy::needless_ifs,
clippy::collapsible_if,
clippy::blocks_in_conditions,
clippy::single_match,
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/auxiliary/proc_macros.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![feature(proc_macro_span)]
#![allow(clippy::needless_if, dead_code)]
#![allow(clippy::needless_ifs, dead_code)]

extern crate proc_macro;

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/blocks_in_conditions.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#![allow(
unused,
unnecessary_transmutes,
clippy::needless_if,
clippy::needless_ifs,
clippy::missing_transmute_annotations
)]
#![warn(clippy::nonminimal_bool)]
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/blocks_in_conditions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#![allow(
unused,
unnecessary_transmutes,
clippy::needless_if,
clippy::needless_ifs,
clippy::missing_transmute_annotations
)]
#![warn(clippy::nonminimal_bool)]
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/bool_comparison.fixed
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(non_local_definitions, clippy::needless_if)]
#![allow(non_local_definitions, clippy::needless_ifs)]
#![warn(clippy::bool_comparison)]
#![allow(clippy::non_canonical_partial_ord_impl)]

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/bool_comparison.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(non_local_definitions, clippy::needless_if)]
#![allow(non_local_definitions, clippy::needless_ifs)]
#![warn(clippy::bool_comparison)]
#![allow(clippy::non_canonical_partial_ord_impl)]

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/cmp_owned/asymmetric_partial_eq.fixed
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![allow(
unused,
clippy::needless_if,
clippy::needless_ifs,
clippy::redundant_clone,
clippy::derive_partial_eq_without_eq
)] // See #5700
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/cmp_owned/asymmetric_partial_eq.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![allow(
unused,
clippy::needless_if,
clippy::needless_ifs,
clippy::redundant_clone,
clippy::derive_partial_eq_without_eq
)] // See #5700
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/collapsible_else_if.fixed
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::assertions_on_constants, clippy::equatable_if_let, clippy::needless_if)]
#![allow(clippy::assertions_on_constants, clippy::equatable_if_let, clippy::needless_ifs)]
#![warn(clippy::collapsible_if, clippy::collapsible_else_if)]

#[rustfmt::skip]
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/collapsible_else_if.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::assertions_on_constants, clippy::equatable_if_let, clippy::needless_if)]
#![allow(clippy::assertions_on_constants, clippy::equatable_if_let, clippy::needless_ifs)]
#![warn(clippy::collapsible_if, clippy::collapsible_else_if)]

#[rustfmt::skip]
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/collapsible_if.fixed
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![allow(
clippy::assertions_on_constants,
clippy::equatable_if_let,
clippy::needless_if,
clippy::needless_ifs,
clippy::nonminimal_bool,
clippy::eq_op,
clippy::redundant_pattern_matching
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/collapsible_if.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![allow(
clippy::assertions_on_constants,
clippy::equatable_if_let,
clippy::needless_if,
clippy::needless_ifs,
clippy::nonminimal_bool,
clippy::eq_op,
clippy::redundant_pattern_matching
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/comparison_to_empty.fixed
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![warn(clippy::comparison_to_empty)]
#![allow(clippy::borrow_deref_ref, clippy::needless_if, clippy::useless_vec)]
#![allow(clippy::borrow_deref_ref, clippy::needless_ifs, clippy::useless_vec)]

fn main() {
// Disallow comparisons to empty
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/comparison_to_empty.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![warn(clippy::comparison_to_empty)]
#![allow(clippy::borrow_deref_ref, clippy::needless_if, clippy::useless_vec)]
#![allow(clippy::borrow_deref_ref, clippy::needless_ifs, clippy::useless_vec)]

fn main() {
// Disallow comparisons to empty
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/crashes/ice-7169.fixed
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::needless_if)]
#![allow(clippy::needless_ifs)]

#[derive(Default)]
struct A<T> {
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/crashes/ice-7169.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::needless_if)]
#![allow(clippy::needless_ifs)]

#[derive(Default)]
struct A<T> {
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/disallowed_names.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//@aux-build:proc_macros.rs
#![allow(
dead_code,
clippy::needless_if,
clippy::needless_ifs,
clippy::similar_names,
clippy::single_match,
clippy::toplevel_ref_arg,
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/double_comparison.fixed
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::needless_if)]
#![allow(clippy::needless_ifs)]

fn main() {
let x = 1;
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/double_comparison.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::needless_if)]
#![allow(clippy::needless_ifs)]

fn main() {
let x = 1;
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/equatable_if_let.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
unused_variables,
dead_code,
clippy::derive_partial_eq_without_eq,
clippy::needless_if
clippy::needless_ifs
)]
#![warn(clippy::equatable_if_let)]

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/equatable_if_let.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
unused_variables,
dead_code,
clippy::derive_partial_eq_without_eq,
clippy::needless_if
clippy::needless_ifs
)]
#![warn(clippy::equatable_if_let)]

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/expect_tool_lint_rfc_2383.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//! This test can't cover every lint from Clippy, rustdoc and potentially other
//! tools that will be developed. This therefore only tests a small subset of lints
#![expect(rustdoc::missing_crate_level_docs)]
#![allow(clippy::needless_if)]
#![allow(clippy::needless_ifs)]

mod rustc_ok {
//! See <https://doc.rust-lang.org/rustc/lints/index.html>
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/filetype_is_file.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::needless_if)]
#![allow(clippy::needless_ifs)]
#![warn(clippy::filetype_is_file)]

fn main() -> std::io::Result<()> {
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/if_same_then_else2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
clippy::equatable_if_let,
clippy::collapsible_if,
clippy::ifs_same_cond,
clippy::needless_if,
clippy::needless_ifs,
clippy::needless_return,
clippy::single_element_loop,
clippy::branches_sharing_code
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/ifs_same_cond.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![warn(clippy::ifs_same_cond)]
#![allow(clippy::if_same_then_else, clippy::needless_if, clippy::needless_else)] // all empty blocks
#![allow(clippy::if_same_then_else, clippy::needless_ifs, clippy::needless_else)] // all empty blocks

fn ifs_same_cond() {
let a = 0;
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/len_zero.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#![allow(
dead_code,
unused,
clippy::needless_if,
clippy::needless_ifs,
clippy::len_without_is_empty,
clippy::const_is_empty
)]
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/len_zero.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#![allow(
dead_code,
unused,
clippy::needless_if,
clippy::needless_ifs,
clippy::len_without_is_empty,
clippy::const_is_empty
)]
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/manual_float_methods.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//@no-rustfix: overlapping suggestions
//@aux-build:proc_macros.rs
#![allow(clippy::needless_if, unused)]
#![allow(clippy::needless_ifs, unused)]
#![warn(clippy::manual_is_infinite, clippy::manual_is_finite)]

// FIXME(f16_f128): add tests for these types once constants are available
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/manual_let_else.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
clippy::let_unit_value,
clippy::match_single_binding,
clippy::never_loop,
clippy::needless_if,
clippy::needless_ifs,
clippy::diverging_sub_expression,
clippy::single_match,
clippy::manual_unwrap_or_default
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/match_overlapping_arm.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![warn(clippy::match_overlapping_arm)]
#![allow(clippy::redundant_pattern_matching)]
#![allow(clippy::if_same_then_else, clippy::equatable_if_let, clippy::needless_if)]
#![allow(clippy::if_same_then_else, clippy::equatable_if_let, clippy::needless_ifs)]

fn overlapping() {
const FOO: u64 = 2;
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/needless_bool/fixable.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
clippy::no_effect,
clippy::if_same_then_else,
clippy::equatable_if_let,
clippy::needless_if,
clippy::needless_ifs,
clippy::needless_return,
clippy::self_named_constructors,
clippy::struct_field_names
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/needless_bool/fixable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
clippy::no_effect,
clippy::if_same_then_else,
clippy::equatable_if_let,
clippy::needless_if,
clippy::needless_ifs,
clippy::needless_return,
clippy::self_named_constructors,
clippy::struct_field_names
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/needless_borrowed_ref.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
irrefutable_let_patterns,
non_shorthand_field_patterns,
clippy::needless_borrow,
clippy::needless_if
clippy::needless_ifs
)]

fn main() {}
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/needless_borrowed_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
irrefutable_let_patterns,
non_shorthand_field_patterns,
clippy::needless_borrow,
clippy::needless_if
clippy::needless_ifs
)]

fn main() {}
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/needless_collect.fixed
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![allow(
unused,
clippy::needless_if,
clippy::needless_ifs,
clippy::suspicious_map,
clippy::iter_count,
clippy::manual_contains
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/needless_collect.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![allow(
unused,
clippy::needless_if,
clippy::needless_ifs,
clippy::suspicious_map,
clippy::iter_count,
clippy::manual_contains
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/needless_collect_indirect.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::uninlined_format_args, clippy::useless_vec, clippy::needless_if)]
#![allow(clippy::uninlined_format_args, clippy::useless_vec, clippy::needless_ifs)]
#![warn(clippy::needless_collect)]
//@no-rustfix
use std::collections::{BinaryHeap, HashMap, HashSet, LinkedList, VecDeque};
Expand Down
Loading