From 4343796fbc7fb4c74801feacbb1ba3c388c6e02d Mon Sep 17 00:00:00 2001 From: Arthur Silva Date: Thu, 4 Jun 2026 23:01:59 +0200 Subject: [PATCH] Fix MSRV build: qualify size_of, add cargo-msrv CI check `std::mem::size_of` was only added to the prelude in Rust 1.80, but the declared MSRV is 1.71. It was used unqualified in linked_slab.rs, breaking builds for downstream crates on Rust < 1.80. Qualify the call as `std::mem::size_of` (matching shard.rs) and add an `msrv` CI job that runs `cargo msrv verify` so this regression is caught in the future. Fixes #118 --- .github/workflows/ci.yml | 21 +++++++++++++++++++++ src/linked_slab.rs | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3a6a5e2..a48224b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,6 +29,27 @@ jobs: - run: cargo check --all-targets --no-default-features --features sharded-lock - run: cargo check --all-targets --features shuttle + msrv: + name: MSRV + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - uses: taiki-e/install-action@v2 + with: + tool: cargo-msrv + # `cargo msrv verify` checks that the crate compiles with the + # `rust-version` declared in Cargo.toml. The default `cargo check` skips + # dev-dependencies, which may require a newer Rust than downstream needs. + - run: cargo msrv verify + - run: cargo msrv verify -- cargo check --features stats + - run: cargo msrv verify -- cargo check --no-default-features + - run: cargo msrv verify -- cargo check --no-default-features --features sharded-lock + test: name: Tests strategy: diff --git a/src/linked_slab.rs b/src/linked_slab.rs index bd840da..7a252c6 100644 --- a/src/linked_slab.rs +++ b/src/linked_slab.rs @@ -247,6 +247,6 @@ impl LinkedSlab { /// It should be noted that if cache key or value is some type like `Vec`, /// the memory allocated in the heap will not be counted. pub fn memory_used(&self) -> usize { - self.entries.len() * size_of::>() + self.entries.len() * std::mem::size_of::>() } }