From 739dbc4c3c349df40c1f60adb318bab954bd582f Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Mon, 24 Mar 2025 16:21:19 -0500 Subject: [PATCH] Fix `clippy::semicolon_if_nothing_returned` warnings --- src/binary_heap.rs | 2 +- src/deque.rs | 2 +- src/histbuf.rs | 6 +++--- src/indexmap.rs | 8 ++++---- src/indexset.rs | 6 +++--- src/lib.rs | 1 + src/linear_map.rs | 2 +- src/pool/arc.rs | 4 ++-- src/pool/boxed.rs | 4 ++-- src/pool/object.rs | 4 ++-- src/pool/treiber.rs | 2 +- src/pool/treiber/cas.rs | 2 +- src/sorted_linked_list.rs | 6 +++--- src/spsc.rs | 4 ++-- src/string/mod.rs | 14 +++++++------- src/vec/mod.rs | 10 +++++----- tests/tsan.rs | 2 +- 17 files changed, 40 insertions(+), 39 deletions(-) diff --git a/src/binary_heap.rs b/src/binary_heap.rs index bd586f71..5125aede 100644 --- a/src/binary_heap.rs +++ b/src/binary_heap.rs @@ -222,7 +222,7 @@ where /// assert!(heap.is_empty()); /// ``` pub fn clear(&mut self) { - self.data.clear() + self.data.clear(); } /// Returns the length of the binary heap. diff --git a/src/deque.rs b/src/deque.rs index 0748615a..b170de1f 100644 --- a/src/deque.rs +++ b/src/deque.rs @@ -896,7 +896,7 @@ impl + ?Sized> Extend for DequeInner { } impl<'a, T: 'a + Copy, S: VecStorage + ?Sized> Extend<&'a T> for DequeInner { fn extend>(&mut self, iter: I) { - self.extend(iter.into_iter().copied()) + self.extend(iter.into_iter().copied()); } } diff --git a/src/histbuf.rs b/src/histbuf.rs index f3ab6995..cedd9eb9 100644 --- a/src/histbuf.rs +++ b/src/histbuf.rs @@ -293,7 +293,7 @@ impl + ?Sized> HistoryBufferInner { ptr::drop_in_place(ptr::slice_from_raw_parts_mut( self.data.borrow_mut().as_mut_ptr().cast::(), self.len(), - )) + )); } } @@ -514,7 +514,7 @@ where where I: IntoIterator, { - self.extend(iter.into_iter().cloned()) + self.extend(iter.into_iter().cloned()); } } @@ -818,7 +818,7 @@ mod tests { assert_eq_iter( [head, tail].iter().copied().flatten(), buffer.oldest_ordered(), - ) + ); } } diff --git a/src/indexmap.rs b/src/indexmap.rs index 54abf8e6..c0afe2b7 100644 --- a/src/indexmap.rs +++ b/src/indexmap.rs @@ -1298,7 +1298,7 @@ where where I: IntoIterator, { - self.extend(iterable.into_iter().map(|(&key, &value)| (key, value))) + self.extend(iterable.into_iter().map(|(&key, &value)| (key, value))); } } @@ -1481,7 +1481,7 @@ mod tests { mem::size_of::() // hash ) + // buckets mem::size_of::() // entries.length - ) + ); } #[test] @@ -1673,7 +1673,7 @@ mod tests { assert_eq!(value, *v.insert(value).unwrap()); } }; - assert_eq!(value, *src.get(&key).unwrap()) + assert_eq!(value, *src.get(&key).unwrap()); } #[test] @@ -1693,7 +1693,7 @@ mod tests { panic!("Entry not found"); } }; - assert_eq!(value2, *src.get(&key).unwrap()) + assert_eq!(value2, *src.get(&key).unwrap()); } #[test] diff --git a/src/indexset.rs b/src/indexset.rs index 1a322d46..438fab80 100644 --- a/src/indexset.rs +++ b/src/indexset.rs @@ -212,7 +212,7 @@ impl IndexSet { /// assert!(v.is_empty()); /// ``` pub fn clear(&mut self) { - self.map.clear() + self.map.clear(); } } @@ -560,7 +560,7 @@ where where I: IntoIterator, { - self.map.extend(iterable.into_iter().map(|k| (k, ()))) + self.map.extend(iterable.into_iter().map(|k| (k, ()))); } } @@ -573,7 +573,7 @@ where where I: IntoIterator, { - self.extend(iterable.into_iter().cloned()) + self.extend(iterable.into_iter().cloned()); } } diff --git a/src/lib.rs b/src/lib.rs index 7bc0cc85..38a0fee2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -147,6 +147,7 @@ clippy::option_if_let_else, clippy::ptr_as_ptr, clippy::doc_markdown, + clippy::semicolon_if_nothing_returned )] pub use binary_heap::BinaryHeap; diff --git a/src/linear_map.rs b/src/linear_map.rs index 718eeff8..ec67ba9e 100644 --- a/src/linear_map.rs +++ b/src/linear_map.rs @@ -85,7 +85,7 @@ where /// assert!(map.is_empty()); /// ``` pub fn clear(&mut self) { - self.buffer.clear() + self.buffer.clear(); } /// Returns true if the map contains a value for the specified key. diff --git a/src/pool/arc.rs b/src/pool/arc.rs index 572da2ff..7007236b 100644 --- a/src/pool/arc.rs +++ b/src/pool/arc.rs @@ -148,7 +148,7 @@ pub trait ArcPool: Sized { /// Add a statically allocated memory block to the memory pool fn manage(block: &'static mut ArcBlock) { - Self::singleton().manage(block) + Self::singleton().manage(block); } } @@ -315,7 +315,7 @@ where where H: Hasher, { - (**self).hash(state) + (**self).hash(state); } } diff --git a/src/pool/boxed.rs b/src/pool/boxed.rs index 807b6748..472840fd 100644 --- a/src/pool/boxed.rs +++ b/src/pool/boxed.rs @@ -166,7 +166,7 @@ pub trait BoxPool: Sized { /// Add a statically allocated memory block to the memory pool fn manage(block: &'static mut BoxBlock) { - Self::singleton().manage(block) + Self::singleton().manage(block); } } @@ -259,7 +259,7 @@ where where H: Hasher, { - (**self).hash(state) + (**self).hash(state); } } diff --git a/src/pool/object.rs b/src/pool/object.rs index 96b10793..1a3f21b3 100644 --- a/src/pool/object.rs +++ b/src/pool/object.rs @@ -135,7 +135,7 @@ pub trait ObjectPool: Sized { /// Adds a statically allocate object to the pool fn manage(block: &'static mut ObjectBlock) { - Self::singleton().manage(block) + Self::singleton().manage(block); } } @@ -262,7 +262,7 @@ where where H: Hasher, { - (**self).hash(state) + (**self).hash(state); } } diff --git a/src/pool/treiber.rs b/src/pool/treiber.rs index 15fb05b7..922520a4 100644 --- a/src/pool/treiber.rs +++ b/src/pool/treiber.rs @@ -27,7 +27,7 @@ where /// - `node` must be a valid pointer /// - aliasing rules must be enforced by the caller. e.g, the same `node` may not be pushed more than once pub unsafe fn push(&self, node: NonNullPtr) { - impl_::push(self, node) + impl_::push(self, node); } pub fn try_pop(&self) -> Option> { diff --git a/src/pool/treiber/cas.rs b/src/pool/treiber/cas.rs index ab426c05..2749cc66 100644 --- a/src/pool/treiber/cas.rs +++ b/src/pool/treiber/cas.rs @@ -87,7 +87,7 @@ where #[inline] fn store(&self, value: Option>, order: Ordering) { self.inner - .store(value.map(NonNullPtr::into_inner).unwrap_or_default(), order) + .store(value.map(NonNullPtr::into_inner).unwrap_or_default(), order); } } diff --git a/src/sorted_linked_list.rs b/src/sorted_linked_list.rs index 2c12ee82..62bb3d5f 100644 --- a/src/sorted_linked_list.rs +++ b/src/sorted_linked_list.rs @@ -770,7 +770,7 @@ where /// ``` #[inline] pub fn finish(self) { - drop(self) + drop(self); } } @@ -925,14 +925,14 @@ mod tests { ll.push(2).unwrap(); ll.push(3).unwrap(); - assert!(ll.is_full()) + assert!(ll.is_full()); } #[test] fn test_empty() { let ll: SortedLinkedList = SortedLinkedList::new_usize(); - assert!(ll.is_empty()) + assert!(ll.is_empty()); } #[test] diff --git a/src/spsc.rs b/src/spsc.rs index c1b94c14..1c53f748 100644 --- a/src/spsc.rs +++ b/src/spsc.rs @@ -308,7 +308,7 @@ impl QueueInner { /// to create a copy of `item`, which could result in `T`'s destructor running on `item` /// twice. pub unsafe fn enqueue_unchecked(&mut self, val: T) { - self.inner_enqueue_unchecked(val) + self.inner_enqueue_unchecked(val); } // The memory for dequeuing is "owned" by the head pointer,. @@ -678,7 +678,7 @@ impl ProducerInner<'_, T, S> { /// See [`Queue::enqueue_unchecked`] #[inline] pub unsafe fn enqueue_unchecked(&mut self, val: T) { - self.rb.inner_enqueue_unchecked(val) + self.rb.inner_enqueue_unchecked(val); } /// Returns if there is any space to enqueue a new item. When this returns true, at diff --git a/src/string/mod.rs b/src/string/mod.rs index 6aee8f27..d8d4ec2a 100644 --- a/src/string/mod.rs +++ b/src/string/mod.rs @@ -519,7 +519,7 @@ impl + ?Sized> StringInner { pub fn truncate(&mut self, new_len: usize) { if new_len <= self.len() { assert!(self.is_char_boundary(new_len)); - self.vec.truncate(new_len) + self.vec.truncate(new_len); } } @@ -619,7 +619,7 @@ impl + ?Sized> StringInner { /// ``` #[inline] pub fn clear(&mut self) { - self.vec.clear() + self.vec.clear(); } } @@ -701,7 +701,7 @@ impl + ?Sized> fmt::Display for StringInner { impl + ?Sized> hash::Hash for StringInner { #[inline] fn hash(&self, hasher: &mut H) { - ::hash(self, hasher) + ::hash(self, hasher); } } @@ -1153,26 +1153,26 @@ mod tests { let number = 5; let float = 3.12; let formatted = format!(15; "{:0>3} plus {float}", number).unwrap(); - assert_eq!(formatted, "005 plus 3.12") + assert_eq!(formatted, "005 plus 3.12"); } #[test] fn format_inferred_capacity() { let number = 5; let float = 3.12; let formatted: String<15> = format!("{:0>3} plus {float}", number).unwrap(); - assert_eq!(formatted, "005 plus 3.12") + assert_eq!(formatted, "005 plus 3.12"); } #[test] fn format_overflow() { let i = 1234567; let formatted = format!(4; "13{}", i); - assert_eq!(formatted, Err(core::fmt::Error)) + assert_eq!(formatted, Err(core::fmt::Error)); } #[test] fn format_plain_string_overflow() { let formatted = format!(2; "123"); - assert_eq!(formatted, Err(core::fmt::Error)) + assert_eq!(formatted, Err(core::fmt::Error)); } } diff --git a/src/vec/mod.rs b/src/vec/mod.rs index c47b74e9..edf9840a 100644 --- a/src/vec/mod.rs +++ b/src/vec/mod.rs @@ -497,7 +497,7 @@ impl + ?Sized> VecInner { I: IntoIterator, { for elem in iter { - self.push(elem).ok().unwrap() + self.push(elem).ok().unwrap(); } } @@ -753,7 +753,7 @@ impl + ?Sized> VecInner { pub unsafe fn set_len(&mut self, new_len: usize) { debug_assert!(new_len <= self.capacity()); - self.len = new_len + self.len = new_len; } /// Removes an element from the vector and returns it. @@ -1223,7 +1223,7 @@ impl + ?Sized> Extend for VecInner { where I: IntoIterator, { - self.extend(iter) + self.extend(iter); } } @@ -1235,7 +1235,7 @@ where where I: IntoIterator, { - self.extend(iter.into_iter().cloned()) + self.extend(iter.into_iter().cloned()); } } @@ -1244,7 +1244,7 @@ where T: core::hash::Hash, { fn hash(&self, state: &mut H) { - <[T] as hash::Hash>::hash(self, state) + <[T] as hash::Hash>::hash(self, state); } } diff --git a/tests/tsan.rs b/tests/tsan.rs index f1657fa4..0d8c0a4d 100644 --- a/tests/tsan.rs +++ b/tests/tsan.rs @@ -229,5 +229,5 @@ fn iterator_properly_wraps() { for (idx, el) in rb.iter().enumerate() { actual[idx] = *el; } - assert_eq!(expected, actual) + assert_eq!(expected, actual); }