From 985c9c059dfc372419c7c1f1eb574f03bcbe1c68 Mon Sep 17 00:00:00 2001 From: Piotr Czarnecki Date: Sun, 1 Dec 2024 21:24:49 +0100 Subject: [PATCH 1/8] Maintain README, github workflow, MSRV --- .github/workflows/rust.yml | 87 +++++++++++++++++++++++--------------- Cargo.toml | 1 + README.md | 2 +- crusader.sh | 11 ----- 4 files changed, 54 insertions(+), 47 deletions(-) delete mode 100755 crusader.sh diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index fa27d5b..1e0177a 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -13,19 +13,23 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Build run: cargo build --verbose - name: Run tests run: cargo test --verbose - - name: Run tests (gecko-ffi) - run: cargo test --tests --verbose + - name: Run miniserde tests + run: cargo test --features miniserde --verbose + - name: Run nanoserde tests + run: cargo test --features nanoserde --verbose + - name: Run borsh tests + run: cargo test --features borsh --verbose miri: name: "Miri" runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Install Miri run: | rustup toolchain install nightly --component miri @@ -37,51 +41,64 @@ jobs: fmt: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@master with: toolchain: stable - profile: minimal components: rustfmt - override: true - - uses: actions-rs/cargo@v1 + - run: cargo fmt --all -- --check + + msrv: + name: Rust ${{matrix.rust}} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + rust: [1.0.0, 1.1.0] + timeout-minutes: 45 + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@master with: - command: fmt - args: --all -- --check - - + toolchain: ${{matrix.rust}} + - run: cargo build + - run: cargo test + + msrv-serde: + name: Rust ${{matrix.rust}} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + rust: [1.31.0, 1.32.0] + timeout-minutes: 45 + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{matrix.rust}} + - run: cargo build + - run: cargo test + - run: cargo test --features serde + clippy: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@master with: toolchain: stable - profile: minimal components: clippy - override: true - - uses: actions-rs/clippy-check@v1 - env: - PWD: ${{ env.GITHUB_WORKSPACE }} - with: - token: ${{ secrets.GITHUB_TOKEN }} - args: --workspace --tests --examples - - + - run: cargo clippy --workspace --tests --examples + docs: runs-on: ubuntu-latest env: RUSTDOCFLAGS: -Dwarnings steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@master with: toolchain: stable - profile: minimal - components: rust-docs - override: true - - uses: swatinem/rust-cache@v1 - - uses: actions-rs/cargo@v1 - with: - command: doc - args: --workspace --no-deps + - uses: swatinem/rust-cache@v2 + - run: cargo doc --workspace --no-deps diff --git a/Cargo.toml b/Cargo.toml index 1c443c5..66dc7a4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,6 +10,7 @@ documentation = "https://docs.rs/bit-vec/" keywords = ["data-structures", "bitvec", "bitmask", "bitmap", "bit"] readme = "README.md" edition = "2015" +rust-version = "1.0" [dependencies] borsh = { version = "1.5", default-features = false, features = ["derive"], optional = true } diff --git a/README.md b/README.md index 2d69953..304cc28 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ [crates.io link]: https://crates.io/crates/bit-vec [docs.rs badge]: https://docs.rs/bit-vec/badge.svg?version=0.8.0 [docs.rs link]: https://docs.rs/bit-vec/0.8.0/bit_vec/ -[github ci badge]: https://github.com/contain-rs/linked-hash-map/workflows/Rust/badge.svg?branch=master +[github ci badge]: https://github.com/contain-rs/bit-vec/workflows/Rust/badge.svg?branch=master [rustc 1.0+]: https://img.shields.io/badge/rustc-1.0%2B-blue.svg [serde_derive: rustc 1.31+]: https://img.shields.io/badge/serde_derive-rustc_1.31+-lightgray.svg [Rust 1.0]: https://blog.rust-lang.org/2015/05/15/Rust-1.0.html diff --git a/crusader.sh b/crusader.sh deleted file mode 100755 index 8becfed..0000000 --- a/crusader.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -git clone https://github.com/brson/cargo-crusader -cd cargo-crusader -cargo build --release -export PATH=$PATH:`pwd`/target/release/ -cd ../ - -cargo crusader - -exit From dfff64e0ae80b6b34ab210e40893cc26c5207aa6 Mon Sep 17 00:00:00 2001 From: Piotr Czarnecki Date: Tue, 16 Jul 2024 23:21:02 +0200 Subject: [PATCH 2/8] 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 d5b540a..435fb85 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 e447b0ae821af786af50ab1f550f5d3f18e4aa49 Mon Sep 17 00:00:00 2001 From: Piotr Czarnecki Date: Sun, 1 Dec 2024 21:29:01 +0100 Subject: [PATCH 3/8] 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 435fb85..8600e39 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] @@ -1959,14 +1959,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(); @@ -1974,9 +1974,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; @@ -2031,7 +2031,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] @@ -2045,17 +2045,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 b25dcbc1fd6522cd5f252ae2f93c4d54832fc9ce Mon Sep 17 00:00:00 2001 From: Piotr Czarnecki Date: Sun, 1 Dec 2024 21:45:03 +0100 Subject: [PATCH 4/8] Formatting --- src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 8600e39..26dc82c 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 06ea2cbdbe86f95a5491e6a9363757deed97ec17 Mon Sep 17 00:00:00 2001 From: Piotr Czarnecki Date: Wed, 29 Jan 2025 19:42:55 +0100 Subject: [PATCH 5/8] Update clippy lints and CI for clippy --- .github/workflows/rust.yml | 3 +++ src/lib.rs | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 1e0177a..92c98c2 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -90,6 +90,9 @@ jobs: toolchain: stable components: clippy - run: cargo clippy --workspace --tests --examples + - run: cargo clippy --workspace --tests --examples --features serde + - run: cargo clippy --workspace --tests --examples --features miniserde + - run: cargo clippy --workspace --tests --examples --features nanoserde docs: runs-on: ubuntu-latest diff --git a/src/lib.rs b/src/lib.rs index 26dc82c..7aa263c 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 bf267de7833359b150a9c1e73373b61c94715b1b Mon Sep 17 00:00:00 2001 From: Piotr Czarnecki Date: Wed, 29 Jan 2025 19:43:02 +0100 Subject: [PATCH 6/8] Update MSRV --- Cargo.toml | 2 +- README.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 66dc7a4..29f3795 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ documentation = "https://docs.rs/bit-vec/" keywords = ["data-structures", "bitvec", "bitmask", "bitmap", "bit"] readme = "README.md" edition = "2015" -rust-version = "1.0" +rust-version = "1.11.0" [dependencies] borsh = { version = "1.5", default-features = false, features = ["derive"], optional = true } diff --git a/README.md b/README.md index 304cc28..c4f113e 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ [![crates.io][crates.io shield]][crates.io link] [![Documentation][docs.rs badge]][docs.rs link] ![Rust CI][github ci badge] -[![rustc 1.0+]][Rust 1.0] +[![rustc 1.11+]][Rust 1.11] [![serde_derive: rustc 1.31+]][Rust 1.31]

@@ -23,7 +23,7 @@ [docs.rs badge]: https://docs.rs/bit-vec/badge.svg?version=0.8.0 [docs.rs link]: https://docs.rs/bit-vec/0.8.0/bit_vec/ [github ci badge]: https://github.com/contain-rs/bit-vec/workflows/Rust/badge.svg?branch=master -[rustc 1.0+]: https://img.shields.io/badge/rustc-1.0%2B-blue.svg +[rustc 1.11+]: https://img.shields.io/badge/rustc-1.11%2B-blue.svg [serde_derive: rustc 1.31+]: https://img.shields.io/badge/serde_derive-rustc_1.31+-lightgray.svg [Rust 1.0]: https://blog.rust-lang.org/2015/05/15/Rust-1.0.html [Rust 1.31]: https://blog.rust-lang.org/2018/12/06/Rust-1.31-and-rust-2018.html From beba3971f89302595207623ac17f831d1515f8be Mon Sep 17 00:00:00 2001 From: Piotr Czarnecki Date: Wed, 29 Jan 2025 19:43:57 +0100 Subject: [PATCH 7/8] Formatting --- src/lib.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 7aa263c..e713611 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 8fd5ae3595acebcd8f3e63c31845f7510a48c144 Mon Sep 17 00:00:00 2001 From: Piotr Czarnecki Date: Wed, 29 Jan 2025 19:47:25 +0100 Subject: [PATCH 8/8] Update versions --- .github/workflows/rust.yml | 4 +++- Cargo.toml | 2 +- src/lib.rs | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 92c98c2..60d314d 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -54,7 +54,7 @@ jobs: strategy: fail-fast: false matrix: - rust: [1.0.0, 1.1.0] + rust: [1.11.0, 1.12.0] timeout-minutes: 45 steps: - uses: actions/checkout@v3 @@ -80,6 +80,8 @@ jobs: - run: cargo build - run: cargo test - run: cargo test --features serde + - run: cargo test --features miniserde + - run: cargo test --features nanoserde clippy: runs-on: ubuntu-latest diff --git a/Cargo.toml b/Cargo.toml index 29f3795..e53dea3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ edition = "2015" rust-version = "1.11.0" [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 e713611..1d8f477 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`. ///