From df953f26a191c49297684db0405e1eb778fa9325 Mon Sep 17 00:00:00 2001 From: Tatsuya Kawano Date: Sun, 3 Nov 2024 10:55:44 +0800 Subject: [PATCH] Fix beta Clippy warnings clippy 0.1.83 (88c1c3c1102 2024-10-18) --- src/common/deque.rs | 2 +- src/sync/base_cache.rs | 8 ++++++++ src/sync/cache.rs | 4 ++++ src/sync/iter.rs | 12 ++++++++++-- src/sync/mapref.rs | 4 ++-- src/unsync/cache.rs | 3 ++- 6 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/common/deque.rs b/src/common/deque.rs index 3a34e10..30d8b0f 100644 --- a/src/common/deque.rs +++ b/src/common/deque.rs @@ -70,7 +70,7 @@ impl Drop for Deque { fn drop(&mut self) { struct DropGuard<'a, T>(&'a mut Deque); - impl<'a, T> Drop for DropGuard<'a, T> { + impl Drop for DropGuard<'_, T> { fn drop(&mut self) { // Continue the same loop we do below. This only runs when a destructor has // panicked. If another one panics this will abort. diff --git a/src/sync/base_cache.rs b/src/sync/base_cache.rs index 1b3b23a..84e8bf4 100644 --- a/src/sync/base_cache.rs +++ b/src/sync/base_cache.rs @@ -219,6 +219,10 @@ where } } +// Clippy beta 0.1.83 (f41c7ed9889 2024-10-31) warns about unused lifetimes on 'a. +// This seems a false positive. The lifetimes are used in the trait bounds. +// https://rust-lang.github.io/rust-clippy/master/index.html#extra_unused_lifetimes +#[allow(clippy::extra_unused_lifetimes)] impl<'a, K, V, S> BaseCache where K: 'a + Eq + Hash, @@ -620,6 +624,10 @@ impl Inner { } } +// Clippy beta 0.1.83 (f41c7ed9889 2024-10-31) warns about unused lifetimes on 'a. +// This seems a false positive. The lifetimes are used in the trait bounds. +// https://rust-lang.github.io/rust-clippy/master/index.html#extra_unused_lifetimes +#[allow(clippy::extra_unused_lifetimes)] impl<'a, K, V, S> Inner where K: 'a + Eq + Hash, diff --git a/src/sync/cache.rs b/src/sync/cache.rs index b238eaa..a5fd466 100644 --- a/src/sync/cache.rs +++ b/src/sync/cache.rs @@ -493,6 +493,10 @@ where } } +// Clippy beta 0.1.83 (f41c7ed9889 2024-10-31) warns about unused lifetimes on 'a. +// This seems a false positive. The lifetimes are used in the trait bounds. +// https://rust-lang.github.io/rust-clippy/master/index.html#extra_unused_lifetimes +#[allow(clippy::extra_unused_lifetimes)] impl<'a, K, V, S> Cache where K: 'a + Eq + Hash, diff --git a/src/sync/iter.rs b/src/sync/iter.rs index 6d3290c..9809819 100644 --- a/src/sync/iter.rs +++ b/src/sync/iter.rs @@ -39,7 +39,11 @@ where } } -unsafe impl<'a, 'i, K, V, S> Send for Iter<'i, K, V, S> +// Clippy beta 0.1.83 (f41c7ed9889 2024-10-31) warns about unused lifetimes on 'a. +// This seems a false positive. The lifetimes are used in the trait bounds. +// https://rust-lang.github.io/rust-clippy/master/index.html#extra_unused_lifetimes +#[allow(clippy::extra_unused_lifetimes)] +unsafe impl<'a, K, V, S> Send for Iter<'_, K, V, S> where K: 'a + Eq + Hash + Send, V: 'a + Send, @@ -47,7 +51,11 @@ where { } -unsafe impl<'a, 'i, K, V, S> Sync for Iter<'i, K, V, S> +// Clippy beta 0.1.83 (f41c7ed9889 2024-10-31) warns about unused lifetimes on 'a. +// This seems a false positive. The lifetimes are used in the trait bounds. +// https://rust-lang.github.io/rust-clippy/master/index.html#extra_unused_lifetimes +#[allow(clippy::extra_unused_lifetimes)] +unsafe impl<'a, K, V, S> Sync for Iter<'_, K, V, S> where K: 'a + Eq + Hash + Sync, V: 'a + Sync, diff --git a/src/sync/mapref.rs b/src/sync/mapref.rs index 8fa1411..c59c13f 100644 --- a/src/sync/mapref.rs +++ b/src/sync/mapref.rs @@ -8,7 +8,7 @@ type DashMapRef<'a, K, V> = pub struct EntryRef<'a, K, V>(DashMapRef<'a, K, V>); -unsafe impl<'a, K, V> Sync for EntryRef<'a, K, V> +unsafe impl Sync for EntryRef<'_, K, V> where K: Eq + Hash + Send + Sync, V: Send + Sync, @@ -36,7 +36,7 @@ where } } -impl<'a, K, V> std::ops::Deref for EntryRef<'a, K, V> +impl std::ops::Deref for EntryRef<'_, K, V> where K: Eq + Hash, { diff --git a/src/unsync/cache.rs b/src/unsync/cache.rs index b0224dc..9edbb5c 100644 --- a/src/unsync/cache.rs +++ b/src/unsync/cache.rs @@ -427,7 +427,8 @@ where /// Like the `invalidate` method, this method does not clear the historic /// popularity estimator of keys so that it retains the client activities of /// trying to retrieve an item. - + // ----------------------------------------------------------------------- + // (The followings are not doc comments) // We need this #[allow(...)] to avoid a false Clippy warning about needless // collect to create keys_to_invalidate. // clippy 0.1.52 (9a1dfd2dc5c 2021-04-30) in Rust 1.52.0-beta.7