From 746333ebb0ac198edde95ffcd33c8b2a2738646a Mon Sep 17 00:00:00 2001 From: Croxx Date: Thu, 28 Nov 2024 23:09:06 +0800 Subject: [PATCH] chore: make clippy happy with rust 1.83.0 (#807) * chore: make clippy happy with rust 1.83.0 Signed-off-by: MrCroxx * test: enable clippy check only with stable toolchain Signed-off-by: MrCroxx --------- Signed-off-by: MrCroxx --- .github/workflows/ci.yml | 5 +- Cargo.toml | 2 +- Makefile | 16 +++--- README.md | 3 +- foyer-common/src/metrics/model.rs | 49 +------------------ foyer-storage/src/small/set.rs | 2 +- ...{storage_test.rs => storage_fuzzy_test.rs} | 2 + 7 files changed, 17 insertions(+), 62 deletions(-) rename foyer-storage/tests/{storage_test.rs => storage_fuzzy_test.rs} (99%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index af66656a..1f3466a5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -122,7 +122,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, macos-latest, windows-latest] - rust_toolchain: [stable, 1.82.0] + rust_toolchain: [stable, 1.81.0] runs-on: ${{ matrix.os }} steps: - name: Checkout @@ -160,7 +160,8 @@ jobs: - name: Run rust format check run: | cargo fmt --all -- --check - - name: Run rust clippy check + - name: Run rust clippy check (stable) + if: matrix.rust_toolchain == 'stable' run: | cargo clippy --all-targets --features tokio-console -- -D warnings cargo clippy --all-targets --features deadlock -- -D warnings diff --git a/Cargo.toml b/Cargo.toml index fe308b1a..a3dabdb2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ members = [ [workspace.package] version = "0.13.0-dev" edition = "2021" -rust-version = "1.82.0" +rust-version = "1.81.0" repository = "https://github.com/foyer-rs/foyer" homepage = "https://foyer.rs" keywords = ["cache", "hybrid"] diff --git a/Makefile b/Makefile index a69d175d..c2a2777b 100644 --- a/Makefile +++ b/Makefile @@ -54,14 +54,14 @@ fast: check test example msrv: shellcheck ./scripts/* ./scripts/minimize-dashboards.sh - cargo +1.82.0 sort -w - cargo +1.82.0 fmt --all - cargo +1.82.0 clippy --all-targets --features deadlock - cargo +1.82.0 clippy --all-targets --features tokio-console - cargo +1.82.0 clippy --all-targets - RUST_BACKTRACE=1 cargo +1.82.0 nextest run --all - RUST_BACKTRACE=1 cargo +1.82.0 test --doc - RUST_BACKTRACE=1 cargo +1.82.0 nextest run --run-ignored ignored-only --no-capture --workspace + cargo +1.81.0 sort -w + cargo +1.81.0 fmt --all + cargo +1.81.0 clippy --all-targets --features deadlock + cargo +1.81.0 clippy --all-targets --features tokio-console + cargo +1.81.0 clippy --all-targets + RUST_BACKTRACE=1 cargo +1.81.0 nextest run --all + RUST_BACKTRACE=1 cargo +1.81.0 test --doc + RUST_BACKTRACE=1 cargo +1.81.0 nextest run --run-ignored ignored-only --no-capture --workspace udeps: RUSTFLAGS="--cfg tokio_unstable -Awarnings" cargo +nightly-2024-08-30 udeps --all-targets diff --git a/README.md b/README.md index 16be9bc0..5d9cbabd 100644 --- a/README.md +++ b/README.md @@ -137,7 +137,6 @@ async fn main() -> Result<()> { .with_eviction_config(LruConfig { high_priority_pool_ratio: 0.1, }) - .with_object_pool_capacity(1024) .with_hash_builder(ahash::RandomState::default()) .with_weighter(|_key, value: &String| value.len()) .storage(Engine::Mixed(0.1)) @@ -223,7 +222,7 @@ More examples and details can be found [here](https://github.com/foyer-rs/foyer/ ## Supported Rust Versions -*foyer* is built against the recent stable release. The minimum supported version is 1.82.0. The current *foyer* version is not guaranteed to build on Rust versions earlier than the minimum supported version. +*foyer* is built against the recent stable release. The minimum supported version is 1.81.0. The current *foyer* version is not guaranteed to build on Rust versions earlier than the minimum supported version. ## Supported Platforms diff --git a/foyer-common/src/metrics/model.rs b/foyer-common/src/metrics/model.rs index f8093cef..ea92d1fe 100644 --- a/foyer-common/src/metrics/model.rs +++ b/foyer-common/src/metrics/model.rs @@ -25,115 +25,68 @@ trait Boxer { } impl Boxer for T {} -// FIXME: https://github.com/rust-lang/rust-analyzer/issues/17685 -// #[expect(missing_docs)] -/// ... ... +#[expect(missing_docs)] #[derive(Debug)] pub struct Metrics { /* in-memory cache metrics */ - /// ... ... pub memory_insert: BoxedCounter, - /// ... ... pub memory_replace: BoxedCounter, - /// ... ... pub memory_hit: BoxedCounter, - /// ... ... pub memory_miss: BoxedCounter, - /// ... ... pub memory_remove: BoxedCounter, - /// ... ... pub memory_evict: BoxedCounter, - /// ... ... pub memory_reinsert: BoxedCounter, - /// ... ... pub memory_release: BoxedCounter, - /// ... ... pub memory_queue: BoxedCounter, - /// ... ... pub memory_fetch: BoxedCounter, - /// ... ... pub memory_usage: BoxedGauge, /* disk cache metrics */ - /// ... ... pub storage_enqueue: BoxedCounter, - /// ... ... pub storage_hit: BoxedCounter, - /// ... ... pub storage_miss: BoxedCounter, - /// ... ... pub storage_delete: BoxedCounter, - /// ... ... pub storage_enqueue_duration: BoxedHistogram, - /// ... ... pub storage_hit_duration: BoxedHistogram, - /// ... ... pub storage_miss_duration: BoxedHistogram, - /// ... ... pub storage_delete_duration: BoxedHistogram, - /// ... ... pub storage_queue_rotate: BoxedCounter, - /// ... ... pub storage_queue_rotate_duration: BoxedHistogram, - /// ... ... pub storage_queue_drop: BoxedCounter, - /// ... ... pub storage_disk_write: BoxedCounter, - /// ... ... pub storage_disk_read: BoxedCounter, - /// ... ... pub storage_disk_flush: BoxedCounter, - /// ... ... pub storage_disk_write_bytes: BoxedCounter, - /// ... ... pub storage_disk_read_bytes: BoxedCounter, - /// ... ... pub storage_disk_write_duration: BoxedHistogram, - /// ... ... pub storage_disk_read_duration: BoxedHistogram, - /// ... ... pub storage_disk_flush_duration: BoxedHistogram, - /// ... ... pub storage_region_total: BoxedGauge, - /// ... ... pub storage_region_clean: BoxedGauge, - /// ... ... pub storage_region_evictable: BoxedGauge, - /// ... ... pub storage_region_size_bytes: BoxedGauge, - /// ... ... pub storage_entry_serialize_duration: BoxedHistogram, - /// ... ... pub storage_entry_deserialize_duration: BoxedHistogram, /* hybrid cache metrics */ - /// ... ... pub hybrid_insert: BoxedCounter, - /// ... ... pub hybrid_hit: BoxedCounter, - /// ... ... pub hybrid_miss: BoxedCounter, - /// ... ... pub hybrid_remove: BoxedCounter, - /// ... ... pub hybrid_insert_duration: BoxedHistogram, - /// ... ... pub hybrid_hit_duration: BoxedHistogram, - /// ... ... pub hybrid_miss_duration: BoxedHistogram, - /// ... ... pub hybrid_remove_duration: BoxedHistogram, - /// ... ... pub hybrid_fetch_duration: BoxedHistogram, } diff --git a/foyer-storage/src/small/set.rs b/foyer-storage/src/small/set.rs index 9ec0bb5c..d930c870 100644 --- a/foyer-storage/src/small/set.rs +++ b/foyer-storage/src/small/set.rs @@ -286,7 +286,7 @@ pub struct SetEntry<'a> { pub value: &'a [u8], } -impl<'a> SetEntry<'a> { +impl SetEntry<'_> { /// Length of the entry with header, key and value included. pub fn len(&self) -> usize { EntryHeader::ENTRY_HEADER_SIZE + self.key.len() + self.value.len() diff --git a/foyer-storage/tests/storage_test.rs b/foyer-storage/tests/storage_fuzzy_test.rs similarity index 99% rename from foyer-storage/tests/storage_test.rs rename to foyer-storage/tests/storage_fuzzy_test.rs index 2c9f4b4c..905ec331 100644 --- a/foyer-storage/tests/storage_test.rs +++ b/foyer-storage/tests/storage_fuzzy_test.rs @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +//! Fuzzy test for foyer storage engines. + #![expect(clippy::identity_op)] use std::{path::Path, sync::Arc, time::Duration};