From 122a332270879cac653b4a91685fa0506590cdd0 Mon Sep 17 00:00:00 2001 From: Alex Macleod Date: Sun, 23 Oct 2022 13:16:29 +0000 Subject: [PATCH] Mark `let_underscore_lock` and `let_underscore_drop` as uplifted --- clippy_lints/src/let_underscore.rs | 162 +++---------------- clippy_lints/src/lib.register_all.rs | 1 - clippy_lints/src/lib.register_correctness.rs | 1 - clippy_lints/src/lib.register_lints.rs | 2 - clippy_lints/src/lib.register_pedantic.rs | 1 - clippy_lints/src/renamed_lints.rs | 6 +- src/docs.rs | 2 - src/docs/let_underscore_drop.txt | 29 ---- src/docs/let_underscore_lock.txt | 20 --- tests/ui/let_underscore_drop.rs | 28 ---- tests/ui/let_underscore_drop.stderr | 27 ---- tests/ui/let_underscore_lock.rs | 36 ----- tests/ui/let_underscore_lock.stderr | 83 ---------- tests/ui/map_flatten_fixable.fixed | 1 - tests/ui/map_flatten_fixable.rs | 1 - tests/ui/map_flatten_fixable.stderr | 18 +-- tests/ui/rename.fixed | 10 +- tests/ui/rename.rs | 10 +- tests/ui/rename.stderr | 76 +++++---- 19 files changed, 96 insertions(+), 418 deletions(-) delete mode 100644 src/docs/let_underscore_drop.txt delete mode 100644 src/docs/let_underscore_lock.txt delete mode 100644 tests/ui/let_underscore_drop.rs delete mode 100644 tests/ui/let_underscore_drop.stderr delete mode 100644 tests/ui/let_underscore_lock.rs delete mode 100644 tests/ui/let_underscore_lock.stderr diff --git a/clippy_lints/src/let_underscore.rs b/clippy_lints/src/let_underscore.rs index b7798b1c1d74..122f7a2c5523 100644 --- a/clippy_lints/src/let_underscore.rs +++ b/clippy_lints/src/let_underscore.rs @@ -1,13 +1,10 @@ use clippy_utils::diagnostics::span_lint_and_help; -use clippy_utils::ty::{is_must_use_ty, is_type_diagnostic_item, match_type}; -use clippy_utils::{is_must_use_func_call, paths}; -use if_chain::if_chain; +use clippy_utils::is_must_use_func_call; +use clippy_utils::ty::is_must_use_ty; use rustc_hir::{Local, PatKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::lint::in_external_macro; -use rustc_middle::ty::subst::GenericArgKind; use rustc_session::{declare_lint_pass, declare_tool_lint}; -use rustc_span::{sym, Symbol}; declare_clippy_lint! { /// ### What it does @@ -33,141 +30,32 @@ declare_clippy_lint! { "non-binding let on a `#[must_use]` expression" } -declare_clippy_lint! { - /// ### What it does - /// Checks for `let _ = sync_lock`. - /// This supports `mutex` and `rwlock` in `std::sync` and `parking_lot`. - /// - /// ### Why is this bad? - /// This statement immediately drops the lock instead of - /// extending its lifetime to the end of the scope, which is often not intended. - /// To extend lock lifetime to the end of the scope, use an underscore-prefixed - /// name instead (i.e. _lock). If you want to explicitly drop the lock, - /// `std::mem::drop` conveys your intention better and is less error-prone. - /// - /// ### Example - /// ```rust,ignore - /// let _ = mutex.lock(); - /// ``` - /// - /// Use instead: - /// ```rust,ignore - /// let _lock = mutex.lock(); - /// ``` - #[clippy::version = "1.43.0"] - pub LET_UNDERSCORE_LOCK, - correctness, - "non-binding let on a synchronization lock" -} - -declare_clippy_lint! { - /// ### What it does - /// Checks for `let _ = ` - /// where expr has a type that implements `Drop` - /// - /// ### Why is this bad? - /// This statement immediately drops the initializer - /// expression instead of extending its lifetime to the end of the scope, which - /// is often not intended. To extend the expression's lifetime to the end of the - /// scope, use an underscore-prefixed name instead (i.e. _var). If you want to - /// explicitly drop the expression, `std::mem::drop` conveys your intention - /// better and is less error-prone. - /// - /// ### Example - /// ```rust - /// # struct DroppableItem; - /// { - /// let _ = DroppableItem; - /// // ^ dropped here - /// /* more code */ - /// } - /// ``` - /// - /// Use instead: - /// ```rust - /// # struct DroppableItem; - /// { - /// let _droppable = DroppableItem; - /// /* more code */ - /// // dropped at end of scope - /// } - /// ``` - #[clippy::version = "1.50.0"] - pub LET_UNDERSCORE_DROP, - pedantic, - "non-binding let on a type that implements `Drop`" -} - -declare_lint_pass!(LetUnderscore => [LET_UNDERSCORE_MUST_USE, LET_UNDERSCORE_LOCK, LET_UNDERSCORE_DROP]); - -const SYNC_GUARD_SYMS: [Symbol; 3] = [sym::MutexGuard, sym::RwLockReadGuard, sym::RwLockWriteGuard]; - -const SYNC_GUARD_PATHS: [&[&str]; 3] = [ - &paths::PARKING_LOT_MUTEX_GUARD, - &paths::PARKING_LOT_RWLOCK_READ_GUARD, - &paths::PARKING_LOT_RWLOCK_WRITE_GUARD, -]; +declare_lint_pass!(LetUnderscore => [LET_UNDERSCORE_MUST_USE]); impl<'tcx> LateLintPass<'tcx> for LetUnderscore { fn check_local(&mut self, cx: &LateContext<'_>, local: &Local<'_>) { - if in_external_macro(cx.tcx.sess, local.span) { - return; - } - - if_chain! { - if let PatKind::Wild = local.pat.kind; - if let Some(init) = local.init; - then { - let init_ty = cx.typeck_results().expr_ty(init); - let contains_sync_guard = init_ty.walk().any(|inner| match inner.unpack() { - GenericArgKind::Type(inner_ty) => { - SYNC_GUARD_SYMS - .iter() - .any(|&sym| is_type_diagnostic_item(cx, inner_ty, sym)) - || SYNC_GUARD_PATHS.iter().any(|path| match_type(cx, inner_ty, path)) - }, - - GenericArgKind::Lifetime(_) | GenericArgKind::Const(_) => false, - }); - if contains_sync_guard { - span_lint_and_help( - cx, - LET_UNDERSCORE_LOCK, - local.span, - "non-binding let on a synchronization lock", - None, - "consider using an underscore-prefixed named \ - binding or dropping explicitly with `std::mem::drop`", - ); - } else if init_ty.needs_drop(cx.tcx, cx.param_env) { - span_lint_and_help( - cx, - LET_UNDERSCORE_DROP, - local.span, - "non-binding `let` on a type that implements `Drop`", - None, - "consider using an underscore-prefixed named \ - binding or dropping explicitly with `std::mem::drop`", - ); - } else if is_must_use_ty(cx, cx.typeck_results().expr_ty(init)) { - span_lint_and_help( - cx, - LET_UNDERSCORE_MUST_USE, - local.span, - "non-binding let on an expression with `#[must_use]` type", - None, - "consider explicitly using expression value", - ); - } else if is_must_use_func_call(cx, init) { - span_lint_and_help( - cx, - LET_UNDERSCORE_MUST_USE, - local.span, - "non-binding let on a result of a `#[must_use]` function", - None, - "consider explicitly using function result", - ); - } + if !in_external_macro(cx.tcx.sess, local.span) + && let PatKind::Wild = local.pat.kind + && let Some(init) = local.init + { + if is_must_use_ty(cx, cx.typeck_results().expr_ty(init)) { + span_lint_and_help( + cx, + LET_UNDERSCORE_MUST_USE, + local.span, + "non-binding let on an expression with `#[must_use]` type", + None, + "consider explicitly using expression value", + ); + } else if is_must_use_func_call(cx, init) { + span_lint_and_help( + cx, + LET_UNDERSCORE_MUST_USE, + local.span, + "non-binding let on a result of a `#[must_use]` function", + None, + "consider explicitly using function result", + ); } } } diff --git a/clippy_lints/src/lib.register_all.rs b/clippy_lints/src/lib.register_all.rs index f5ad52ba1892..edb5334ee068 100644 --- a/clippy_lints/src/lib.register_all.rs +++ b/clippy_lints/src/lib.register_all.rs @@ -104,7 +104,6 @@ store.register_group(true, "clippy::all", Some("clippy_all"), vec![ LintId::of(len_zero::COMPARISON_TO_EMPTY), LintId::of(len_zero::LEN_WITHOUT_IS_EMPTY), LintId::of(len_zero::LEN_ZERO), - LintId::of(let_underscore::LET_UNDERSCORE_LOCK), LintId::of(lifetimes::EXTRA_UNUSED_LIFETIMES), LintId::of(lifetimes::NEEDLESS_LIFETIMES), LintId::of(literal_representation::INCONSISTENT_DIGIT_GROUPING), diff --git a/clippy_lints/src/lib.register_correctness.rs b/clippy_lints/src/lib.register_correctness.rs index bb94037ec2e7..d17efab4f2a3 100644 --- a/clippy_lints/src/lib.register_correctness.rs +++ b/clippy_lints/src/lib.register_correctness.rs @@ -30,7 +30,6 @@ store.register_group(true, "clippy::correctness", Some("clippy_correctness"), ve LintId::of(inherent_to_string::INHERENT_TO_STRING_SHADOW_DISPLAY), LintId::of(inline_fn_without_body::INLINE_FN_WITHOUT_BODY), LintId::of(invalid_utf8_in_unchecked::INVALID_UTF8_IN_UNCHECKED), - LintId::of(let_underscore::LET_UNDERSCORE_LOCK), LintId::of(literal_representation::MISTYPED_LITERAL_SUFFIXES), LintId::of(loops::ITER_NEXT_LOOP), LintId::of(loops::NEVER_LOOP), diff --git a/clippy_lints/src/lib.register_lints.rs b/clippy_lints/src/lib.register_lints.rs index 800e3a876713..10f8f1236bff 100644 --- a/clippy_lints/src/lib.register_lints.rs +++ b/clippy_lints/src/lib.register_lints.rs @@ -214,8 +214,6 @@ store.register_lints(&[ len_zero::LEN_WITHOUT_IS_EMPTY, len_zero::LEN_ZERO, let_if_seq::USELESS_LET_IF_SEQ, - let_underscore::LET_UNDERSCORE_DROP, - let_underscore::LET_UNDERSCORE_LOCK, let_underscore::LET_UNDERSCORE_MUST_USE, lifetimes::EXTRA_UNUSED_LIFETIMES, lifetimes::NEEDLESS_LIFETIMES, diff --git a/clippy_lints/src/lib.register_pedantic.rs b/clippy_lints/src/lib.register_pedantic.rs index 2ead71a68fab..768b3347c2aa 100644 --- a/clippy_lints/src/lib.register_pedantic.rs +++ b/clippy_lints/src/lib.register_pedantic.rs @@ -39,7 +39,6 @@ store.register_group(true, "clippy::pedantic", Some("clippy_pedantic"), vec![ LintId::of(items_after_statements::ITEMS_AFTER_STATEMENTS), LintId::of(iter_not_returning_iterator::ITER_NOT_RETURNING_ITERATOR), LintId::of(large_stack_arrays::LARGE_STACK_ARRAYS), - LintId::of(let_underscore::LET_UNDERSCORE_DROP), LintId::of(literal_representation::LARGE_DIGIT_GROUPS), LintId::of(literal_representation::UNREADABLE_LITERAL), LintId::of(loops::EXPLICIT_INTO_ITER_LOOP), diff --git a/clippy_lints/src/renamed_lints.rs b/clippy_lints/src/renamed_lints.rs index 76d6ad0b23e6..30abee7ec3d0 100644 --- a/clippy_lints/src/renamed_lints.rs +++ b/clippy_lints/src/renamed_lints.rs @@ -11,8 +11,6 @@ pub static RENAMED_LINTS: &[(&str, &str)] = &[ ("clippy::disallowed_method", "clippy::disallowed_methods"), ("clippy::disallowed_type", "clippy::disallowed_types"), ("clippy::eval_order_dependence", "clippy::mixed_read_write_in_expression"), - ("clippy::for_loop_over_option", "for_loops_over_fallibles"), - ("clippy::for_loop_over_result", "for_loops_over_fallibles"), ("clippy::identity_conversion", "clippy::useless_conversion"), ("clippy::if_let_some_result", "clippy::match_result_ok"), ("clippy::logic_bug", "clippy::overly_complex_bool_expr"), @@ -31,10 +29,14 @@ pub static RENAMED_LINTS: &[(&str, &str)] = &[ ("clippy::to_string_in_display", "clippy::recursive_format_impl"), ("clippy::zero_width_space", "clippy::invisible_characters"), ("clippy::drop_bounds", "drop_bounds"), + ("clippy::for_loop_over_option", "for_loops_over_fallibles"), + ("clippy::for_loop_over_result", "for_loops_over_fallibles"), ("clippy::for_loops_over_fallibles", "for_loops_over_fallibles"), ("clippy::into_iter_on_array", "array_into_iter"), ("clippy::invalid_atomic_ordering", "invalid_atomic_ordering"), ("clippy::invalid_ref", "invalid_value"), + ("clippy::let_underscore_drop", "let_underscore_drop"), + ("clippy::let_underscore_lock", "let_underscore_lock"), ("clippy::mem_discriminant_non_enum", "enum_intrinsics_non_enums"), ("clippy::panic_params", "non_fmt_panics"), ("clippy::positional_named_format_parameters", "named_arguments_used_positionally"), diff --git a/src/docs.rs b/src/docs.rs index c033ad294a38..88875c97f498 100644 --- a/src/docs.rs +++ b/src/docs.rs @@ -247,8 +247,6 @@ docs! { "len_without_is_empty", "len_zero", "let_and_return", - "let_underscore_drop", - "let_underscore_lock", "let_underscore_must_use", "let_unit_value", "linkedlist", diff --git a/src/docs/let_underscore_drop.txt b/src/docs/let_underscore_drop.txt deleted file mode 100644 index 29ce9bf50ce6..000000000000 --- a/src/docs/let_underscore_drop.txt +++ /dev/null @@ -1,29 +0,0 @@ -### What it does -Checks for `let _ = ` -where expr has a type that implements `Drop` - -### Why is this bad? -This statement immediately drops the initializer -expression instead of extending its lifetime to the end of the scope, which -is often not intended. To extend the expression's lifetime to the end of the -scope, use an underscore-prefixed name instead (i.e. _var). If you want to -explicitly drop the expression, `std::mem::drop` conveys your intention -better and is less error-prone. - -### Example -``` -{ - let _ = DroppableItem; - // ^ dropped here - /* more code */ -} -``` - -Use instead: -``` -{ - let _droppable = DroppableItem; - /* more code */ - // dropped at end of scope -} -``` \ No newline at end of file diff --git a/src/docs/let_underscore_lock.txt b/src/docs/let_underscore_lock.txt deleted file mode 100644 index bd8217fb58b3..000000000000 --- a/src/docs/let_underscore_lock.txt +++ /dev/null @@ -1,20 +0,0 @@ -### What it does -Checks for `let _ = sync_lock`. -This supports `mutex` and `rwlock` in `std::sync` and `parking_lot`. - -### Why is this bad? -This statement immediately drops the lock instead of -extending its lifetime to the end of the scope, which is often not intended. -To extend lock lifetime to the end of the scope, use an underscore-prefixed -name instead (i.e. _lock). If you want to explicitly drop the lock, -`std::mem::drop` conveys your intention better and is less error-prone. - -### Example -``` -let _ = mutex.lock(); -``` - -Use instead: -``` -let _lock = mutex.lock(); -``` \ No newline at end of file diff --git a/tests/ui/let_underscore_drop.rs b/tests/ui/let_underscore_drop.rs deleted file mode 100644 index 11b50492ab29..000000000000 --- a/tests/ui/let_underscore_drop.rs +++ /dev/null @@ -1,28 +0,0 @@ -#![warn(clippy::let_underscore_drop)] -#![allow(clippy::let_unit_value)] - -struct Droppable; - -impl Drop for Droppable { - fn drop(&mut self) {} -} - -fn main() { - let unit = (); - let boxed = Box::new(()); - let droppable = Droppable; - let optional = Some(Droppable); - - let _ = (); - let _ = Box::new(()); - let _ = Droppable; - let _ = Some(Droppable); - - // no lint for reference - let _ = droppable_ref(); -} - -#[must_use] -fn droppable_ref() -> &'static mut Droppable { - unimplemented!() -} diff --git a/tests/ui/let_underscore_drop.stderr b/tests/ui/let_underscore_drop.stderr deleted file mode 100644 index 324b7cd431d4..000000000000 --- a/tests/ui/let_underscore_drop.stderr +++ /dev/null @@ -1,27 +0,0 @@ -error: non-binding `let` on a type that implements `Drop` - --> $DIR/let_underscore_drop.rs:17:5 - | -LL | let _ = Box::new(()); - | ^^^^^^^^^^^^^^^^^^^^^ - | - = help: consider using an underscore-prefixed named binding or dropping explicitly with `std::mem::drop` - = note: `-D clippy::let-underscore-drop` implied by `-D warnings` - -error: non-binding `let` on a type that implements `Drop` - --> $DIR/let_underscore_drop.rs:18:5 - | -LL | let _ = Droppable; - | ^^^^^^^^^^^^^^^^^^ - | - = help: consider using an underscore-prefixed named binding or dropping explicitly with `std::mem::drop` - -error: non-binding `let` on a type that implements `Drop` - --> $DIR/let_underscore_drop.rs:19:5 - | -LL | let _ = Some(Droppable); - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: consider using an underscore-prefixed named binding or dropping explicitly with `std::mem::drop` - -error: aborting due to 3 previous errors - diff --git a/tests/ui/let_underscore_lock.rs b/tests/ui/let_underscore_lock.rs deleted file mode 100644 index 7a7c4e924995..000000000000 --- a/tests/ui/let_underscore_lock.rs +++ /dev/null @@ -1,36 +0,0 @@ -#![warn(clippy::let_underscore_lock)] - -extern crate parking_lot; - -fn main() { - let m = std::sync::Mutex::new(()); - let rw = std::sync::RwLock::new(()); - - let _ = m.lock(); - let _ = rw.read(); - let _ = rw.write(); - let _ = m.try_lock(); - let _ = rw.try_read(); - let _ = rw.try_write(); - - // These shouldn't throw an error. - let _ = m; - let _ = rw; - - use parking_lot::{lock_api::RawMutex, Mutex, RwLock}; - - let p_m: Mutex<()> = Mutex::const_new(RawMutex::INIT, ()); - let _ = p_m.lock(); - - let p_m1 = Mutex::new(0); - let _ = p_m1.lock(); - - let p_rw = RwLock::new(0); - let _ = p_rw.read(); - let _ = p_rw.write(); - - // These shouldn't throw an error. - let _ = p_m; - let _ = p_m1; - let _ = p_rw; -} diff --git a/tests/ui/let_underscore_lock.stderr b/tests/ui/let_underscore_lock.stderr deleted file mode 100644 index d7779e7b6c48..000000000000 --- a/tests/ui/let_underscore_lock.stderr +++ /dev/null @@ -1,83 +0,0 @@ -error: non-binding let on a synchronization lock - --> $DIR/let_underscore_lock.rs:9:5 - | -LL | let _ = m.lock(); - | ^^^^^^^^^^^^^^^^^ - | - = help: consider using an underscore-prefixed named binding or dropping explicitly with `std::mem::drop` - = note: `-D clippy::let-underscore-lock` implied by `-D warnings` - -error: non-binding let on a synchronization lock - --> $DIR/let_underscore_lock.rs:10:5 - | -LL | let _ = rw.read(); - | ^^^^^^^^^^^^^^^^^^ - | - = help: consider using an underscore-prefixed named binding or dropping explicitly with `std::mem::drop` - -error: non-binding let on a synchronization lock - --> $DIR/let_underscore_lock.rs:11:5 - | -LL | let _ = rw.write(); - | ^^^^^^^^^^^^^^^^^^^ - | - = help: consider using an underscore-prefixed named binding or dropping explicitly with `std::mem::drop` - -error: non-binding let on a synchronization lock - --> $DIR/let_underscore_lock.rs:12:5 - | -LL | let _ = m.try_lock(); - | ^^^^^^^^^^^^^^^^^^^^^ - | - = help: consider using an underscore-prefixed named binding or dropping explicitly with `std::mem::drop` - -error: non-binding let on a synchronization lock - --> $DIR/let_underscore_lock.rs:13:5 - | -LL | let _ = rw.try_read(); - | ^^^^^^^^^^^^^^^^^^^^^^ - | - = help: consider using an underscore-prefixed named binding or dropping explicitly with `std::mem::drop` - -error: non-binding let on a synchronization lock - --> $DIR/let_underscore_lock.rs:14:5 - | -LL | let _ = rw.try_write(); - | ^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: consider using an underscore-prefixed named binding or dropping explicitly with `std::mem::drop` - -error: non-binding let on a synchronization lock - --> $DIR/let_underscore_lock.rs:23:5 - | -LL | let _ = p_m.lock(); - | ^^^^^^^^^^^^^^^^^^^ - | - = help: consider using an underscore-prefixed named binding or dropping explicitly with `std::mem::drop` - -error: non-binding let on a synchronization lock - --> $DIR/let_underscore_lock.rs:26:5 - | -LL | let _ = p_m1.lock(); - | ^^^^^^^^^^^^^^^^^^^^ - | - = help: consider using an underscore-prefixed named binding or dropping explicitly with `std::mem::drop` - -error: non-binding let on a synchronization lock - --> $DIR/let_underscore_lock.rs:29:5 - | -LL | let _ = p_rw.read(); - | ^^^^^^^^^^^^^^^^^^^^ - | - = help: consider using an underscore-prefixed named binding or dropping explicitly with `std::mem::drop` - -error: non-binding let on a synchronization lock - --> $DIR/let_underscore_lock.rs:30:5 - | -LL | let _ = p_rw.write(); - | ^^^^^^^^^^^^^^^^^^^^^ - | - = help: consider using an underscore-prefixed named binding or dropping explicitly with `std::mem::drop` - -error: aborting due to 10 previous errors - diff --git a/tests/ui/map_flatten_fixable.fixed b/tests/ui/map_flatten_fixable.fixed index 312819a0a2cf..53628ef6531a 100644 --- a/tests/ui/map_flatten_fixable.fixed +++ b/tests/ui/map_flatten_fixable.fixed @@ -1,7 +1,6 @@ // run-rustfix #![warn(clippy::all, clippy::pedantic)] -#![allow(clippy::let_underscore_drop)] #![allow(clippy::missing_docs_in_private_items)] #![allow(clippy::map_identity)] #![allow(clippy::redundant_closure)] diff --git a/tests/ui/map_flatten_fixable.rs b/tests/ui/map_flatten_fixable.rs index 3fbf4f9a1b04..76016c8ed3cd 100644 --- a/tests/ui/map_flatten_fixable.rs +++ b/tests/ui/map_flatten_fixable.rs @@ -1,7 +1,6 @@ // run-rustfix #![warn(clippy::all, clippy::pedantic)] -#![allow(clippy::let_underscore_drop)] #![allow(clippy::missing_docs_in_private_items)] #![allow(clippy::map_identity)] #![allow(clippy::redundant_closure)] diff --git a/tests/ui/map_flatten_fixable.stderr b/tests/ui/map_flatten_fixable.stderr index c91f0b9ae94f..b6b0c4d09c37 100644 --- a/tests/ui/map_flatten_fixable.stderr +++ b/tests/ui/map_flatten_fixable.stderr @@ -1,5 +1,5 @@ error: called `map(..).flatten()` on `Iterator` - --> $DIR/map_flatten_fixable.rs:18:47 + --> $DIR/map_flatten_fixable.rs:17:47 | LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(option_id).flatten().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `filter_map` and remove the `.flatten()`: `filter_map(option_id)` @@ -7,43 +7,43 @@ LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(option_id).flatten().coll = note: `-D clippy::map-flatten` implied by `-D warnings` error: called `map(..).flatten()` on `Iterator` - --> $DIR/map_flatten_fixable.rs:19:47 + --> $DIR/map_flatten_fixable.rs:18:47 | LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(option_id_ref).flatten().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `filter_map` and remove the `.flatten()`: `filter_map(option_id_ref)` error: called `map(..).flatten()` on `Iterator` - --> $DIR/map_flatten_fixable.rs:20:47 + --> $DIR/map_flatten_fixable.rs:19:47 | LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(option_id_closure).flatten().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `filter_map` and remove the `.flatten()`: `filter_map(option_id_closure)` error: called `map(..).flatten()` on `Iterator` - --> $DIR/map_flatten_fixable.rs:21:47 + --> $DIR/map_flatten_fixable.rs:20:47 | LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(|x| x.checked_add(1)).flatten().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `filter_map` and remove the `.flatten()`: `filter_map(|x| x.checked_add(1))` error: called `map(..).flatten()` on `Iterator` - --> $DIR/map_flatten_fixable.rs:24:47 + --> $DIR/map_flatten_fixable.rs:23:47 | LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(|x| 0..x).flatten().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `flat_map` and remove the `.flatten()`: `flat_map(|x| 0..x)` error: called `map(..).flatten()` on `Option` - --> $DIR/map_flatten_fixable.rs:27:40 + --> $DIR/map_flatten_fixable.rs:26:40 | LL | let _: Option<_> = (Some(Some(1))).map(|x| x).flatten(); | ^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `and_then` and remove the `.flatten()`: `and_then(|x| x)` error: called `map(..).flatten()` on `Result` - --> $DIR/map_flatten_fixable.rs:30:42 + --> $DIR/map_flatten_fixable.rs:29:42 | LL | let _: Result<_, &str> = (Ok(Ok(1))).map(|x| x).flatten(); | ^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `and_then` and remove the `.flatten()`: `and_then(|x| x)` error: called `map(..).flatten()` on `Iterator` - --> $DIR/map_flatten_fixable.rs:39:10 + --> $DIR/map_flatten_fixable.rs:38:10 | LL | .map(|n| match n { | __________^ @@ -72,7 +72,7 @@ LL ~ }); | error: called `map(..).flatten()` on `Option` - --> $DIR/map_flatten_fixable.rs:59:10 + --> $DIR/map_flatten_fixable.rs:58:10 | LL | .map(|_| { | __________^ diff --git a/tests/ui/rename.fixed b/tests/ui/rename.fixed index 8beae8dee085..967460667a63 100644 --- a/tests/ui/rename.fixed +++ b/tests/ui/rename.fixed @@ -12,7 +12,6 @@ #![allow(clippy::disallowed_methods)] #![allow(clippy::disallowed_types)] #![allow(clippy::mixed_read_write_in_expression)] -#![allow(for_loops_over_fallibles)] #![allow(clippy::useless_conversion)] #![allow(clippy::match_result_ok)] #![allow(clippy::overly_complex_bool_expr)] @@ -27,9 +26,12 @@ #![allow(clippy::recursive_format_impl)] #![allow(clippy::invisible_characters)] #![allow(drop_bounds)] +#![allow(for_loops_over_fallibles)] #![allow(array_into_iter)] #![allow(invalid_atomic_ordering)] #![allow(invalid_value)] +#![allow(let_underscore_drop)] +#![allow(let_underscore_lock)] #![allow(enum_intrinsics_non_enums)] #![allow(non_fmt_panics)] #![allow(named_arguments_used_positionally)] @@ -45,8 +47,6 @@ #![warn(clippy::disallowed_methods)] #![warn(clippy::disallowed_types)] #![warn(clippy::mixed_read_write_in_expression)] -#![warn(for_loops_over_fallibles)] -#![warn(for_loops_over_fallibles)] #![warn(clippy::useless_conversion)] #![warn(clippy::match_result_ok)] #![warn(clippy::overly_complex_bool_expr)] @@ -66,9 +66,13 @@ #![warn(clippy::invisible_characters)] #![warn(drop_bounds)] #![warn(for_loops_over_fallibles)] +#![warn(for_loops_over_fallibles)] +#![warn(for_loops_over_fallibles)] #![warn(array_into_iter)] #![warn(invalid_atomic_ordering)] #![warn(invalid_value)] +#![warn(let_underscore_drop)] +#![warn(let_underscore_lock)] #![warn(enum_intrinsics_non_enums)] #![warn(non_fmt_panics)] #![warn(named_arguments_used_positionally)] diff --git a/tests/ui/rename.rs b/tests/ui/rename.rs index 9e665047baae..8031075ba35e 100644 --- a/tests/ui/rename.rs +++ b/tests/ui/rename.rs @@ -12,7 +12,6 @@ #![allow(clippy::disallowed_methods)] #![allow(clippy::disallowed_types)] #![allow(clippy::mixed_read_write_in_expression)] -#![allow(for_loops_over_fallibles)] #![allow(clippy::useless_conversion)] #![allow(clippy::match_result_ok)] #![allow(clippy::overly_complex_bool_expr)] @@ -27,9 +26,12 @@ #![allow(clippy::recursive_format_impl)] #![allow(clippy::invisible_characters)] #![allow(drop_bounds)] +#![allow(for_loops_over_fallibles)] #![allow(array_into_iter)] #![allow(invalid_atomic_ordering)] #![allow(invalid_value)] +#![allow(let_underscore_drop)] +#![allow(let_underscore_lock)] #![allow(enum_intrinsics_non_enums)] #![allow(non_fmt_panics)] #![allow(named_arguments_used_positionally)] @@ -45,8 +47,6 @@ #![warn(clippy::disallowed_method)] #![warn(clippy::disallowed_type)] #![warn(clippy::eval_order_dependence)] -#![warn(clippy::for_loop_over_option)] -#![warn(clippy::for_loop_over_result)] #![warn(clippy::identity_conversion)] #![warn(clippy::if_let_some_result)] #![warn(clippy::logic_bug)] @@ -65,10 +65,14 @@ #![warn(clippy::to_string_in_display)] #![warn(clippy::zero_width_space)] #![warn(clippy::drop_bounds)] +#![warn(clippy::for_loop_over_option)] +#![warn(clippy::for_loop_over_result)] #![warn(clippy::for_loops_over_fallibles)] #![warn(clippy::into_iter_on_array)] #![warn(clippy::invalid_atomic_ordering)] #![warn(clippy::invalid_ref)] +#![warn(clippy::let_underscore_drop)] +#![warn(clippy::let_underscore_lock)] #![warn(clippy::mem_discriminant_non_enum)] #![warn(clippy::panic_params)] #![warn(clippy::positional_named_format_parameters)] diff --git a/tests/ui/rename.stderr b/tests/ui/rename.stderr index 63eb565185f0..07fa5d7e010c 100644 --- a/tests/ui/rename.stderr +++ b/tests/ui/rename.stderr @@ -1,5 +1,5 @@ error: lint `clippy::blacklisted_name` has been renamed to `clippy::disallowed_names` - --> $DIR/rename.rs:39:9 + --> $DIR/rename.rs:41:9 | LL | #![warn(clippy::blacklisted_name)] | ^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::disallowed_names` @@ -7,65 +7,53 @@ LL | #![warn(clippy::blacklisted_name)] = note: `-D renamed-and-removed-lints` implied by `-D warnings` error: lint `clippy::block_in_if_condition_expr` has been renamed to `clippy::blocks_in_if_conditions` - --> $DIR/rename.rs:40:9 + --> $DIR/rename.rs:42:9 | LL | #![warn(clippy::block_in_if_condition_expr)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::blocks_in_if_conditions` error: lint `clippy::block_in_if_condition_stmt` has been renamed to `clippy::blocks_in_if_conditions` - --> $DIR/rename.rs:41:9 + --> $DIR/rename.rs:43:9 | LL | #![warn(clippy::block_in_if_condition_stmt)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::blocks_in_if_conditions` error: lint `clippy::box_vec` has been renamed to `clippy::box_collection` - --> $DIR/rename.rs:42:9 + --> $DIR/rename.rs:44:9 | LL | #![warn(clippy::box_vec)] | ^^^^^^^^^^^^^^^ help: use the new name: `clippy::box_collection` error: lint `clippy::const_static_lifetime` has been renamed to `clippy::redundant_static_lifetimes` - --> $DIR/rename.rs:43:9 + --> $DIR/rename.rs:45:9 | LL | #![warn(clippy::const_static_lifetime)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::redundant_static_lifetimes` error: lint `clippy::cyclomatic_complexity` has been renamed to `clippy::cognitive_complexity` - --> $DIR/rename.rs:44:9 + --> $DIR/rename.rs:46:9 | LL | #![warn(clippy::cyclomatic_complexity)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::cognitive_complexity` error: lint `clippy::disallowed_method` has been renamed to `clippy::disallowed_methods` - --> $DIR/rename.rs:45:9 + --> $DIR/rename.rs:47:9 | LL | #![warn(clippy::disallowed_method)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::disallowed_methods` error: lint `clippy::disallowed_type` has been renamed to `clippy::disallowed_types` - --> $DIR/rename.rs:46:9 + --> $DIR/rename.rs:48:9 | LL | #![warn(clippy::disallowed_type)] | ^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::disallowed_types` error: lint `clippy::eval_order_dependence` has been renamed to `clippy::mixed_read_write_in_expression` - --> $DIR/rename.rs:47:9 + --> $DIR/rename.rs:49:9 | LL | #![warn(clippy::eval_order_dependence)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::mixed_read_write_in_expression` -error: lint `clippy::for_loop_over_option` has been renamed to `for_loops_over_fallibles` - --> $DIR/rename.rs:48:9 - | -LL | #![warn(clippy::for_loop_over_option)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `for_loops_over_fallibles` - -error: lint `clippy::for_loop_over_result` has been renamed to `for_loops_over_fallibles` - --> $DIR/rename.rs:49:9 - | -LL | #![warn(clippy::for_loop_over_result)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `for_loops_over_fallibles` - error: lint `clippy::identity_conversion` has been renamed to `clippy::useless_conversion` --> $DIR/rename.rs:50:9 | @@ -174,65 +162,89 @@ error: lint `clippy::drop_bounds` has been renamed to `drop_bounds` LL | #![warn(clippy::drop_bounds)] | ^^^^^^^^^^^^^^^^^^^ help: use the new name: `drop_bounds` -error: lint `clippy::for_loops_over_fallibles` has been renamed to `for_loops_over_fallibles` +error: lint `clippy::for_loop_over_option` has been renamed to `for_loops_over_fallibles` --> $DIR/rename.rs:68:9 | +LL | #![warn(clippy::for_loop_over_option)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `for_loops_over_fallibles` + +error: lint `clippy::for_loop_over_result` has been renamed to `for_loops_over_fallibles` + --> $DIR/rename.rs:69:9 + | +LL | #![warn(clippy::for_loop_over_result)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `for_loops_over_fallibles` + +error: lint `clippy::for_loops_over_fallibles` has been renamed to `for_loops_over_fallibles` + --> $DIR/rename.rs:70:9 + | LL | #![warn(clippy::for_loops_over_fallibles)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `for_loops_over_fallibles` error: lint `clippy::into_iter_on_array` has been renamed to `array_into_iter` - --> $DIR/rename.rs:69:9 + --> $DIR/rename.rs:71:9 | LL | #![warn(clippy::into_iter_on_array)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `array_into_iter` error: lint `clippy::invalid_atomic_ordering` has been renamed to `invalid_atomic_ordering` - --> $DIR/rename.rs:70:9 + --> $DIR/rename.rs:72:9 | LL | #![warn(clippy::invalid_atomic_ordering)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `invalid_atomic_ordering` error: lint `clippy::invalid_ref` has been renamed to `invalid_value` - --> $DIR/rename.rs:71:9 + --> $DIR/rename.rs:73:9 | LL | #![warn(clippy::invalid_ref)] | ^^^^^^^^^^^^^^^^^^^ help: use the new name: `invalid_value` +error: lint `clippy::let_underscore_drop` has been renamed to `let_underscore_drop` + --> $DIR/rename.rs:74:9 + | +LL | #![warn(clippy::let_underscore_drop)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `let_underscore_drop` + +error: lint `clippy::let_underscore_lock` has been renamed to `let_underscore_lock` + --> $DIR/rename.rs:75:9 + | +LL | #![warn(clippy::let_underscore_lock)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `let_underscore_lock` + error: lint `clippy::mem_discriminant_non_enum` has been renamed to `enum_intrinsics_non_enums` - --> $DIR/rename.rs:72:9 + --> $DIR/rename.rs:76:9 | LL | #![warn(clippy::mem_discriminant_non_enum)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `enum_intrinsics_non_enums` error: lint `clippy::panic_params` has been renamed to `non_fmt_panics` - --> $DIR/rename.rs:73:9 + --> $DIR/rename.rs:77:9 | LL | #![warn(clippy::panic_params)] | ^^^^^^^^^^^^^^^^^^^^ help: use the new name: `non_fmt_panics` error: lint `clippy::positional_named_format_parameters` has been renamed to `named_arguments_used_positionally` - --> $DIR/rename.rs:74:9 + --> $DIR/rename.rs:78:9 | LL | #![warn(clippy::positional_named_format_parameters)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `named_arguments_used_positionally` error: lint `clippy::temporary_cstring_as_ptr` has been renamed to `temporary_cstring_as_ptr` - --> $DIR/rename.rs:75:9 + --> $DIR/rename.rs:79:9 | LL | #![warn(clippy::temporary_cstring_as_ptr)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `temporary_cstring_as_ptr` error: lint `clippy::unknown_clippy_lints` has been renamed to `unknown_lints` - --> $DIR/rename.rs:76:9 + --> $DIR/rename.rs:80:9 | LL | #![warn(clippy::unknown_clippy_lints)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `unknown_lints` error: lint `clippy::unused_label` has been renamed to `unused_labels` - --> $DIR/rename.rs:77:9 + --> $DIR/rename.rs:81:9 | LL | #![warn(clippy::unused_label)] | ^^^^^^^^^^^^^^^^^^^^ help: use the new name: `unused_labels` -error: aborting due to 39 previous errors +error: aborting due to 41 previous errors