From c3c997817c5c8da61275ef0641c9294596172c89 Mon Sep 17 00:00:00 2001 From: Emily Schmidt Date: Tue, 8 Oct 2024 10:17:08 +0100 Subject: [PATCH] table_seq: fix clippy warnings (needless lifetimes, unnecessary returns) --- table_seq/src/map_seq.rs | 38 ++++++++++++++++---------------- table_seq/src/set_seq.rs | 14 ++++++------ table_seq/src/table_seq.rs | 6 ++--- table_seq/src/table_seq/entry.rs | 4 ++-- table_seq/src/table_seq/iter.rs | 8 +++---- table_seq/src/table_seq/table.rs | 6 ++--- 6 files changed, 38 insertions(+), 38 deletions(-) diff --git a/table_seq/src/map_seq.rs b/table_seq/src/map_seq.rs index 5d98a7d..6e8518e 100644 --- a/table_seq/src/map_seq.rs +++ b/table_seq/src/map_seq.rs @@ -228,13 +228,13 @@ pub struct MapSeqMap<'a, K, V, S> { map: usize, } -impl<'a, K, V, S> Clone for MapSeqMap<'a, K, V, S> { +impl Clone for MapSeqMap<'_, K, V, S> { fn clone(&self) -> Self { *self } } -impl<'a, K, V, S> Copy for MapSeqMap<'a, K, V, S> {} +impl Copy for MapSeqMap<'_, K, V, S> {} impl<'a, K, V, S> std::ops::Deref for MapSeqMapMut<'a, K, V, S> { type Target = MapSeqMap<'a, K, V, S>; @@ -246,13 +246,13 @@ impl<'a, K, V, S> std::ops::Deref for MapSeqMapMut<'a, K, V, S> { } } -impl<'a, K: fmt::Debug, V: fmt::Debug, S> fmt::Debug for MapSeqMap<'a, K, V, S> { +impl fmt::Debug for MapSeqMap<'_, K, V, S> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_set().entries(self.iter()).finish() } } -impl<'a, K: fmt::Debug, V: fmt::Debug, S> fmt::Debug for MapSeqMapMut<'a, K, V, S> { +impl fmt::Debug for MapSeqMapMut<'_, K, V, S> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_set().entries(self.iter()).finish() } @@ -296,7 +296,7 @@ impl<'a, K, V, S> MapSeqMap<'a, K, V, S> { } } -impl<'a, K, V, S> MapSeqMapMut<'a, K, V, S> { +impl MapSeqMapMut<'_, K, V, S> { /// Discards all elements of the map. #[inline(always)] pub fn clear(&mut self) { @@ -319,7 +319,7 @@ impl<'a, K, V, S> MapSeqMapMut<'a, K, V, S> { } } -impl<'a, K: Eq + Hash, V, S: BuildHasher> MapSeqMap<'a, K, V, S> { +impl MapSeqMap<'_, K, V, S> { /// Returns `true` if the map contains an element for the given key. #[inline(always)] pub fn contains_key(&self, key: &Q) -> bool @@ -353,7 +353,7 @@ impl<'a, K: Eq + Hash, V, S: BuildHasher> MapSeqMap<'a, K, V, S> { } } -impl<'a, K: Eq + Hash, V, S: BuildHasher> MapSeqMapMut<'a, K, V, S> { +impl MapSeqMapMut<'_, K, V, S> { /// Returns a mutable reference to the value corresponding to the given key. #[inline(always)] pub fn get_mut(&mut self, key: &Q) -> Option<&mut V> @@ -545,7 +545,7 @@ pub struct MapIter<'a, K, V> { inner: SubtableIter<'a, MapEntry>, } -impl<'a, K, V> Default for MapIter<'a, K, V> { +impl Default for MapIter<'_, K, V> { #[inline(always)] fn default() -> Self { Self { @@ -568,7 +568,7 @@ impl<'a, K, V> Iterator for MapIter<'a, K, V> { } } -impl<'a, K, V> ExactSizeIterator for MapIter<'a, K, V> { +impl ExactSizeIterator for MapIter<'_, K, V> { #[inline(always)] fn len(&self) -> usize { self.inner.len() @@ -580,7 +580,7 @@ pub struct MapKeys<'a, K, V> { inner: SubtableIter<'a, MapEntry>, } -impl<'a, K, V> Default for MapKeys<'a, K, V> { +impl Default for MapKeys<'_, K, V> { #[inline(always)] fn default() -> Self { Self { @@ -603,7 +603,7 @@ impl<'a, K, V> Iterator for MapKeys<'a, K, V> { } } -impl<'a, K, V> ExactSizeIterator for MapKeys<'a, K, V> { +impl ExactSizeIterator for MapKeys<'_, K, V> { #[inline(always)] fn len(&self) -> usize { self.inner.len() @@ -615,7 +615,7 @@ pub struct MapValues<'a, K, V> { inner: SubtableIter<'a, MapEntry>, } -impl<'a, K, V> Default for MapValues<'a, K, V> { +impl Default for MapValues<'_, K, V> { #[inline(always)] fn default() -> Self { Self { @@ -638,7 +638,7 @@ impl<'a, K, V> Iterator for MapValues<'a, K, V> { } } -impl<'a, K, V> ExactSizeIterator for MapValues<'a, K, V> { +impl ExactSizeIterator for MapValues<'_, K, V> { #[inline(always)] fn len(&self) -> usize { self.inner.len() @@ -650,7 +650,7 @@ pub struct MapIterMut<'a, K, V> { inner: SubtableIterMut<'a, MapEntry>, } -impl<'a, K, V> Default for MapIterMut<'a, K, V> { +impl Default for MapIterMut<'_, K, V> { #[inline(always)] fn default() -> Self { Self { @@ -675,7 +675,7 @@ impl<'a, K, V> Iterator for MapIterMut<'a, K, V> { } } -impl<'a, K, V> ExactSizeIterator for MapIterMut<'a, K, V> { +impl ExactSizeIterator for MapIterMut<'_, K, V> { #[inline(always)] fn len(&self) -> usize { self.inner.len() @@ -700,7 +700,7 @@ impl<'a, K, V, S> IntoIterator for MapSeqMapMut<'a, K, V, S> { } } -impl<'a, K, V, S> Extend<(K, V)> for MapSeqMapMut<'a, K, V, S> +impl Extend<(K, V)> for MapSeqMapMut<'_, K, V, S> where K: Eq + Hash, S: BuildHasher, @@ -712,7 +712,7 @@ where } } -impl<'a, 'b, K, V, S> Extend<(&'b K, &'b V)> for MapSeqMapMut<'a, K, V, S> +impl<'b, K, V, S> Extend<(&'b K, &'b V)> for MapSeqMapMut<'_, K, V, S> where K: Eq + Hash + Copy, V: Copy, @@ -725,7 +725,7 @@ where } } -impl<'a, K, Q, V, S> std::ops::Index<&Q> for MapSeqMap<'a, K, V, S> +impl std::ops::Index<&Q> for MapSeqMap<'_, K, V, S> where K: Eq + Hash + Borrow, S: BuildHasher, @@ -738,7 +738,7 @@ where } } -impl<'a, K, Q, V, S> std::ops::Index<&Q> for MapSeqMapMut<'a, K, V, S> +impl std::ops::Index<&Q> for MapSeqMapMut<'_, K, V, S> where K: Eq + Hash + Borrow, S: BuildHasher, diff --git a/table_seq/src/set_seq.rs b/table_seq/src/set_seq.rs index 630400e..800da04 100644 --- a/table_seq/src/set_seq.rs +++ b/table_seq/src/set_seq.rs @@ -13,7 +13,7 @@ pub struct SetIter<'a, T> { inner: SubtableIter<'a, T>, } -impl<'a, T> Default for SetIter<'a, T> { +impl Default for SetIter<'_, T> { #[inline(always)] fn default() -> Self { Self { @@ -36,7 +36,7 @@ impl<'a, T> Iterator for SetIter<'a, T> { } } -impl<'a, T> ExactSizeIterator for SetIter<'a, T> { +impl ExactSizeIterator for SetIter<'_, T> { #[inline(always)] fn len(&self) -> usize { self.inner.len() @@ -273,13 +273,13 @@ impl<'a, T, S> std::ops::Deref for SetSeqSetMut<'a, T, S> { } } -impl<'a, T: fmt::Debug, S> fmt::Debug for SetSeqSet<'a, T, S> { +impl fmt::Debug for SetSeqSet<'_, T, S> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_set().entries(self.iter()).finish() } } -impl<'a, T: fmt::Debug, S> fmt::Debug for SetSeqSetMut<'a, T, S> { +impl fmt::Debug for SetSeqSetMut<'_, T, S> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_set().entries(self.iter()).finish() } @@ -307,7 +307,7 @@ impl<'a, T, S> SetSeqSet<'a, T, S> { } } -impl<'a, T, S> SetSeqSetMut<'a, T, S> { +impl SetSeqSetMut<'_, T, S> { /// Discards all elements of the set. #[inline(always)] pub fn clear(&mut self) { @@ -315,7 +315,7 @@ impl<'a, T, S> SetSeqSetMut<'a, T, S> { } } -impl<'a, T: Eq + Hash, S: BuildHasher> SetSeqSet<'a, T, S> { +impl SetSeqSet<'_, T, S> { /// Checks whether a given value is an element of the set. #[inline(always)] pub fn contains(&self, value: &Q) -> bool @@ -337,7 +337,7 @@ impl<'a, T: Eq + Hash, S: BuildHasher> SetSeqSet<'a, T, S> { } } -impl<'a, T: Eq + Hash, S: BuildHasher> SetSeqSetMut<'a, T, S> { +impl SetSeqSetMut<'_, T, S> { /// Inserts a value into the set. /// /// If the value is already present, the given value is discarded and the set is not modified. diff --git a/table_seq/src/table_seq.rs b/table_seq/src/table_seq.rs index 596689b..82c1d45 100644 --- a/table_seq/src/table_seq.rs +++ b/table_seq/src/table_seq.rs @@ -65,7 +65,7 @@ impl fmt::Debug for TableSeq { #[derive(Clone)] struct SubtableFmt<'a, T>(&'a TableSeq, usize); - impl<'a, T: fmt::Debug> fmt::Debug for SubtableFmt<'a, T> { + impl fmt::Debug for SubtableFmt<'_, T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_set().entries(self.0.subtable_iter(self.1)).finish() } @@ -96,7 +96,7 @@ const ALLOCATOR_SHIFT: u32 = 20; /// Drop guard to prevent exposing invalid entries on panics. struct InvalidateChunkOnDrop<'a, T>(&'a mut Chunk); -impl<'a, T> Drop for InvalidateChunkOnDrop<'a, T> { +impl Drop for InvalidateChunkOnDrop<'_, T> { fn drop(&mut self) { // This is only called when the drop implementation of an entry panics. In that situation, // we do the minimum necessary to remain memory safe but spend no effort cleaning up. Since @@ -111,7 +111,7 @@ impl<'a, T> Drop for InvalidateChunkOnDrop<'a, T> { } } -impl<'a, T> InvalidateChunkOnDrop<'a, T> { +impl InvalidateChunkOnDrop<'_, T> { fn defuse(self) { let _ = ManuallyDrop::new(self); } diff --git a/table_seq/src/table_seq/entry.rs b/table_seq/src/table_seq/entry.rs index 528c380..5f9f736 100644 --- a/table_seq/src/table_seq/entry.rs +++ b/table_seq/src/table_seq/entry.rs @@ -96,11 +96,11 @@ impl TableSeq { match chunk.meta.entry_type(chunk_slot) { EntryType::Empty => { - return Entry::Vacant(VacantEntry { + Entry::Vacant(VacantEntry { tables: self, subtable, kind: VacantEntryKind::EmptyTable, - }); + }) } EntryType::Single => { let node = chunk.node(chunk_alloc); diff --git a/table_seq/src/table_seq/iter.rs b/table_seq/src/table_seq/iter.rs index 8967b98..877fddf 100644 --- a/table_seq/src/table_seq/iter.rs +++ b/table_seq/src/table_seq/iter.rs @@ -5,7 +5,7 @@ pub struct SubtableIter<'a, T> { inner: SubtableIterInner<'a, T>, } -impl<'a, T> Default for SubtableIter<'a, T> { +impl Default for SubtableIter<'_, T> { fn default() -> Self { Self { inner: SubtableIterInner::Small([].as_slice().iter()), @@ -62,7 +62,7 @@ impl<'a, T> Iterator for SubtableIter<'a, T> { } } -impl<'a, T> ExactSizeIterator for SubtableIter<'a, T> { +impl ExactSizeIterator for SubtableIter<'_, T> { fn len(&self) -> usize { match &self.inner { SubtableIterInner::Small(iter) => iter.len(), @@ -76,7 +76,7 @@ pub struct SubtableIterMut<'a, T> { inner: SubtableIterMutInner<'a, T>, } -impl<'a, T> Default for SubtableIterMut<'a, T> { +impl Default for SubtableIterMut<'_, T> { fn default() -> Self { Self { inner: SubtableIterMutInner::Small(Default::default()), @@ -133,7 +133,7 @@ impl<'a, T> Iterator for SubtableIterMut<'a, T> { } } -impl<'a, T> ExactSizeIterator for SubtableIterMut<'a, T> { +impl ExactSizeIterator for SubtableIterMut<'_, T> { fn len(&self) -> usize { match &self.inner { SubtableIterMutInner::Small(iter) => iter.len(), diff --git a/table_seq/src/table_seq/table.rs b/table_seq/src/table_seq/table.rs index f704194..43a5106 100644 --- a/table_seq/src/table_seq/table.rs +++ b/table_seq/src/table_seq/table.rs @@ -263,12 +263,12 @@ impl SmallSubtable { } if self.len() == SMALL_SUBTABLE_CAPACITY { - return SmallSubtableEntry::FullTable(self); + SmallSubtableEntry::FullTable(self) } else { - return SmallSubtableEntry::Vacant(SmallSubtableVacantEntry { + SmallSubtableEntry::Vacant(SmallSubtableVacantEntry { table: self, byte_hash, - }); + }) } }