From c037b63b7534e2216f411f0539825df9d10ba0c6 Mon Sep 17 00:00:00 2001 From: Piotr Czarnecki Date: Tue, 16 Jul 2024 23:21:02 +0200 Subject: [PATCH 1/6] Enable some clippy lints --- src/lib.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 7a64527..ddce910 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -85,6 +85,10 @@ #![doc(html_root_url = "https://docs.rs/bit-vec/0.8.0")] #![no_std] +#![forbid(clippy::shadow_reuse)] +#![forbid(clippy::shadow_same)] +#![forbid(clippy::shadow_unrelated)] + #[cfg(any(test, feature = "std"))] #[macro_use] extern crate std; @@ -1888,11 +1892,10 @@ pub struct IterMut<'a, B: 'a + BitBlock = u32> { impl<'a, B: 'a + BitBlock> IterMut<'a, B> { fn get(&mut self, index: Option) -> Option> { - let index = index?; - let value = (*self.vec).borrow().get(index)?; + let value = (*self.vec).borrow().get(index?)?; Some(MutBorrowedBit { vec: self.vec.clone(), - index, + index: index?, #[cfg(debug_assertions)] old_value: value, new_value: value, From 1758f9f7f82e413c58fb52cd3d2c3549c75b4d95 Mon Sep 17 00:00:00 2001 From: Piotr Czarnecki Date: Sun, 1 Dec 2024 21:29:01 +0100 Subject: [PATCH 2/6] Fix clippy warnings for elidable lifetimes --- src/lib.rs | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index ddce910..989c158 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -85,9 +85,9 @@ #![doc(html_root_url = "https://docs.rs/bit-vec/0.8.0")] #![no_std] -#![forbid(clippy::shadow_reuse)] -#![forbid(clippy::shadow_same)] -#![forbid(clippy::shadow_unrelated)] +#![deny(clippy::shadow_reuse)] +#![deny(clippy::shadow_same)] +#![deny(clippy::shadow_unrelated)] #[cfg(any(test, feature = "std"))] #[macro_use] @@ -1903,7 +1903,7 @@ impl<'a, B: 'a + BitBlock> IterMut<'a, B> { } } -impl<'a, B: BitBlock> Deref for MutBorrowedBit<'a, B> { +impl Deref for MutBorrowedBit<'_, B> { type Target = bool; fn deref(&self) -> &Self::Target { @@ -1911,13 +1911,13 @@ impl<'a, B: BitBlock> Deref for MutBorrowedBit<'a, B> { } } -impl<'a, B: BitBlock> DerefMut for MutBorrowedBit<'a, B> { +impl DerefMut for MutBorrowedBit<'_, B> { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.new_value } } -impl<'a, B: BitBlock> Drop for MutBorrowedBit<'a, B> { +impl Drop for MutBorrowedBit<'_, B> { fn drop(&mut self) { let mut vec = (*self.vec).borrow_mut(); #[cfg(debug_assertions)] @@ -1930,7 +1930,7 @@ impl<'a, B: BitBlock> Drop for MutBorrowedBit<'a, B> { } } -impl<'a, B: BitBlock> Iterator for Iter<'a, B> { +impl Iterator for Iter<'_, B> { type Item = bool; #[inline] @@ -1966,14 +1966,14 @@ impl<'a, B: BitBlock> Iterator for IterMut<'a, B> { } } -impl<'a, B: BitBlock> DoubleEndedIterator for Iter<'a, B> { +impl DoubleEndedIterator for Iter<'_, B> { #[inline] fn next_back(&mut self) -> Option { self.range.next_back().map(|i| self.bit_vec.get(i).unwrap()) } } -impl<'a, B: BitBlock> DoubleEndedIterator for IterMut<'a, B> { +impl DoubleEndedIterator for IterMut<'_, B> { #[inline] fn next_back(&mut self) -> Option { let index = self.range.next_back(); @@ -1981,9 +1981,9 @@ impl<'a, B: BitBlock> DoubleEndedIterator for IterMut<'a, B> { } } -impl<'a, B: BitBlock> ExactSizeIterator for Iter<'a, B> {} +impl ExactSizeIterator for Iter<'_, B> {} -impl<'a, B: BitBlock> ExactSizeIterator for IterMut<'a, B> {} +impl ExactSizeIterator for IterMut<'_, B> {} impl<'a, B: BitBlock> IntoIterator for &'a BitVec { type Item = bool; @@ -2038,7 +2038,7 @@ pub struct Blocks<'a, B: 'a> { iter: slice::Iter<'a, B>, } -impl<'a, B: BitBlock> Iterator for Blocks<'a, B> { +impl Iterator for Blocks<'_, B> { type Item = B; #[inline] @@ -2052,17 +2052,21 @@ impl<'a, B: BitBlock> Iterator for Blocks<'a, B> { } } -impl<'a, B: BitBlock> DoubleEndedIterator for Blocks<'a, B> { +impl DoubleEndedIterator for Blocks<'_, B> { #[inline] fn next_back(&mut self) -> Option { self.iter.next_back().cloned() } } -impl<'a, B: BitBlock> ExactSizeIterator for Blocks<'a, B> {} +impl ExactSizeIterator for Blocks<'_, B> {} #[cfg(test)] mod tests { + #![allow(clippy::shadow_reuse)] + #![allow(clippy::shadow_same)] + #![allow(clippy::shadow_unrelated)] + use super::{BitVec, Iter, Vec}; // This is stupid, but I want to differentiate from a "random" 32 From b6885f8bc319115563341bdb1bac9f8198a6499a Mon Sep 17 00:00:00 2001 From: Piotr Czarnecki Date: Sun, 1 Dec 2024 21:45:03 +0100 Subject: [PATCH 3/6] Formatting --- src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 989c158..0103e80 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -84,7 +84,6 @@ #![doc(html_root_url = "https://docs.rs/bit-vec/0.8.0")] #![no_std] - #![deny(clippy::shadow_reuse)] #![deny(clippy::shadow_same)] #![deny(clippy::shadow_unrelated)] From abacbdd5c996a2f9578d68218f06cebb744dd82a Mon Sep 17 00:00:00 2001 From: Piotr Czarnecki Date: Sun, 8 Jun 2025 15:23:51 +0200 Subject: [PATCH 4/6] Update clippy lints and CI for clippy --- src/lib.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 0103e80..3e1757b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -84,10 +84,16 @@ #![doc(html_root_url = "https://docs.rs/bit-vec/0.8.0")] #![no_std] + #![deny(clippy::shadow_reuse)] #![deny(clippy::shadow_same)] #![deny(clippy::shadow_unrelated)] +#![warn(clippy::multiple_inherent_impl)] +#![warn(clippy::multiple_crate_versions)] +#![warn(clippy::single_match)] +#![warn(clippy::missing_safety_doc)] + #[cfg(any(test, feature = "std"))] #[macro_use] extern crate std; From 458f00aaee2a54c55cd9bfb327fbed9f0d699b2e Mon Sep 17 00:00:00 2001 From: Piotr Czarnecki Date: Wed, 29 Jan 2025 19:43:57 +0100 Subject: [PATCH 5/6] Formatting --- src/lib.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 3e1757b..423739a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -84,11 +84,9 @@ #![doc(html_root_url = "https://docs.rs/bit-vec/0.8.0")] #![no_std] - #![deny(clippy::shadow_reuse)] #![deny(clippy::shadow_same)] #![deny(clippy::shadow_unrelated)] - #![warn(clippy::multiple_inherent_impl)] #![warn(clippy::multiple_crate_versions)] #![warn(clippy::single_match)] From 9be18ffccb9e8e256503472aeae96ed34aba25a6 Mon Sep 17 00:00:00 2001 From: Piotr Czarnecki Date: Wed, 29 Jan 2025 19:47:25 +0100 Subject: [PATCH 6/6] Update versions --- Cargo.toml | 2 +- src/lib.rs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index cb520b5..b5a88ef 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ edition = "2021" rust-version = "1.67" [dependencies] -borsh = { version = "1.5", default-features = false, features = ["derive"], optional = true } +borsh = { version = "1.5.5", default-features = false, features = ["derive"], optional = true } serde = { version = "1.0", default-features = false, features = ["derive"], optional = true } miniserde = { version = "0.1", optional = true } nanoserde = { version = "0.1", optional = true } diff --git a/src/lib.rs b/src/lib.rs index 423739a..ad32249 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -312,7 +312,9 @@ impl BitVec { pub fn new() -> Self { Default::default() } +} +impl BitVec { /// Creates a `BitVec` that holds `nbits` elements, setting each element /// to `bit`. ///