From fec88f0fdf880b87c6f13bcfd9ac64af599f9757 Mon Sep 17 00:00:00 2001 From: Croxx Date: Fri, 6 Sep 2024 15:22:26 +0800 Subject: [PATCH] refactor: bump rust toolchain to 1.81.0 (#687) * refactor: replace allow with expect and warn allow usage Signed-off-by: MrCroxx * refactor: upgrade msrv to 1.81.0, remove trace feature for foyer-bench Signed-off-by: MrCroxx * fix: fix build Signed-off-by: MrCroxx * fix: fix check on non-linux Signed-off-by: MrCroxx --------- Signed-off-by: MrCroxx --- .github/template/template.yml | 4 +- .github/workflows/main.yml | 4 +- .github/workflows/pull-request.yml | 4 +- Makefile | 20 +++++----- README.md | 2 +- foyer-bench/Cargo.toml | 14 ------- foyer-bench/src/main.rs | 44 ++-------------------- foyer-common/src/code.rs | 2 - foyer-common/src/event.rs | 3 +- foyer-common/src/lib.rs | 1 + foyer-common/src/metrics.rs | 50 ++++++++++++++++++++++++- foyer-intrusive/src/lib.rs | 4 +- foyer-memory/src/eviction/s3fifo.rs | 5 +-- foyer-memory/src/eviction/test_utils.rs | 2 - foyer-memory/src/generic.rs | 22 +++-------- foyer-memory/src/lib.rs | 1 + foyer-storage/src/engine.rs | 8 +--- foyer-storage/src/large/flusher.rs | 3 +- foyer-storage/src/large/reclaimer.rs | 3 +- foyer-storage/src/large/recover.rs | 3 +- foyer-storage/src/large/scanner.rs | 6 +-- foyer-storage/src/lib.rs | 1 + foyer-storage/src/picker/mod.rs | 3 +- foyer-storage/src/region.rs | 6 +-- foyer-storage/src/serde.rs | 1 - foyer-storage/src/small/generic.rs | 8 +--- foyer-storage/src/storage/either.rs | 2 - foyer-storage/src/storage/mod.rs | 2 - foyer-storage/tests/storage_test.rs | 3 +- foyer-util/src/compact_bloom_filter.rs | 3 +- foyer-util/src/iostat.rs | 5 +-- foyer-util/src/lib.rs | 2 + foyer/Cargo.toml | 2 +- foyer/src/hybrid/cache.rs | 2 +- foyer/src/lib.rs | 1 + 35 files changed, 99 insertions(+), 147 deletions(-) diff --git a/.github/template/template.yml b/.github/template/template.yml index ee8bd182..f2fde5bb 100644 --- a/.github/template/template.yml +++ b/.github/template/template.yml @@ -3,7 +3,7 @@ name: on: env: - RUST_TOOLCHAIN_NIGHTLY: nightly-2024-03-17 + RUST_TOOLCHAIN_NIGHTLY: nightly-2024-07-19 CARGO_TERM_COLOR: always CACHE_KEY_SUFFIX: 20240821 @@ -113,7 +113,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, macos-latest, windows-latest] - rust_toolchain: [stable, 1.77] + rust_toolchain: [stable, 1.81.0] runs-on: ${{ matrix.os }} steps: - name: Checkout diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 062b3542..1c03e6d2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,7 +11,7 @@ on: branches: [main] workflow_dispatch: env: - RUST_TOOLCHAIN_NIGHTLY: nightly-2024-03-17 + RUST_TOOLCHAIN_NIGHTLY: nightly-2024-07-19 CARGO_TERM_COLOR: always CACHE_KEY_SUFFIX: 20240821 jobs: @@ -120,7 +120,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, macos-latest, windows-latest] - rust_toolchain: [stable, 1.77] + rust_toolchain: [stable, 1.81.0] runs-on: ${{ matrix.os }} steps: - name: Checkout diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index e2bbd251..cfe463a2 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -10,7 +10,7 @@ on: pull_request: branches: [main] env: - RUST_TOOLCHAIN_NIGHTLY: nightly-2024-03-17 + RUST_TOOLCHAIN_NIGHTLY: nightly-2024-07-19 CARGO_TERM_COLOR: always CACHE_KEY_SUFFIX: 20240821 jobs: @@ -119,7 +119,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, macos-latest, windows-latest] - rust_toolchain: [stable, 1.77] + rust_toolchain: [stable, 1.81.0] runs-on: ${{ matrix.os }} steps: - name: Checkout diff --git a/Makefile b/Makefile index a5545ef6..edb7c932 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,6 @@ check-all: cargo fmt --all cargo clippy --all-targets --features deadlock cargo clippy --all-targets --features tokio-console - cargo clippy --all-targets --features trace cargo clippy --all-targets --features sanity cargo clippy --all-targets --features mtrace cargo clippy --all-targets @@ -56,18 +55,17 @@ msrv: shellcheck ./scripts/* ./.github/template/generate.sh ./scripts/minimize-dashboards.sh - cargo +1.77 sort -w - cargo +1.77 fmt --all - cargo +1.77 clippy --all-targets --features deadlock - cargo +1.77 clippy --all-targets --features tokio-console - cargo +1.77 clippy --all-targets --features trace - cargo +1.77 clippy --all-targets - RUST_BACKTRACE=1 cargo +1.77 nextest run --all - RUST_BACKTRACE=1 cargo +1.77 test --doc - RUST_BACKTRACE=1 cargo +1.77 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-03-17 udeps --all-targets + RUSTFLAGS="--cfg tokio_unstable -Awarnings" cargo +nightly-2024-07-19 udeps --all-targets monitor: ./scripts/monitor.sh diff --git a/README.md b/README.md index 587f3872..69223b42 100644 --- a/README.md +++ b/README.md @@ -194,7 +194,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.77. 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. ## Development State & Roadmap diff --git a/foyer-bench/Cargo.toml b/foyer-bench/Cargo.toml index 88e11c51..0faff8a4 100644 --- a/foyer-bench/Cargo.toml +++ b/foyer-bench/Cargo.toml @@ -23,13 +23,6 @@ hdrhistogram = "7" itertools = { workspace = true } metrics = { workspace = true } metrics-exporter-prometheus = "0.15" -opentelemetry = { version = "0.24", optional = true } -opentelemetry-otlp = { version = "0.17", optional = true } -opentelemetry-semantic-conventions = { version = "0.16", optional = true } -opentelemetry_sdk = { version = "0.24", features = [ - "rt-tokio", - "trace", -], optional = true } parking_lot = "0.12" rand = "0.8.5" serde = { workspace = true } @@ -46,13 +39,6 @@ tikv-jemallocator = { version = "0.6", optional = true } [features] deadlock = ["parking_lot/deadlock_detection", "foyer/deadlock"] tokio-console = ["console-subscriber"] -trace = [ - "opentelemetry", - "opentelemetry_sdk", - "opentelemetry-otlp", - "tracing-opentelemetry", - "opentelemetry-semantic-conventions", -] strict_assertions = ["foyer/strict_assertions"] sanity = ["foyer/sanity"] jemalloc = ["tikv-jemallocator"] diff --git a/foyer-bench/src/main.rs b/foyer-bench/src/main.rs index 70f9f3af..98e69925 100644 --- a/foyer-bench/src/main.rs +++ b/foyer-bench/src/main.rs @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#![warn(clippy::allow_attributes)] + mod analyze; mod rate; mod text; @@ -337,46 +339,6 @@ fn setup() { console_subscriber::init(); } -#[cfg(feature = "trace")] -fn setup() { - use opentelemetry_sdk::{ - trace::{BatchConfigBuilder, Config}, - Resource, - }; - use opentelemetry_semantic_conventions::resource::SERVICE_NAME; - use tracing::Level; - use tracing_subscriber::{filter::Targets, prelude::*}; - - let tracing_config = Config::default().with_resource(Resource::new(vec![opentelemetry::KeyValue::new( - SERVICE_NAME, - "foyer-bench", - )])); - let batch_config = BatchConfigBuilder::default() - .with_max_queue_size(1048576) - .with_max_export_batch_size(4096) - .with_max_concurrent_exports(4) - .build(); - - let tracer = opentelemetry_otlp::new_pipeline() - .tracing() - .with_exporter(opentelemetry_otlp::new_exporter().tonic()) - .with_tracing_config(tracing_config) - .with_batch_config(batch_config) - .install_batch(opentelemetry_sdk::runtime::Tokio) - .unwrap(); - let opentelemetry_layer = tracing_opentelemetry::layer().with_tracer(tracer); - tracing_subscriber::registry() - .with( - Targets::new() - .with_target("foyer_storage", Level::DEBUG) - .with_target("foyer_common", Level::DEBUG) - .with_target("foyer_intrusive", Level::DEBUG) - .with_target("foyer_storage_bench", Level::DEBUG), - ) - .with(opentelemetry_layer) - .init(); -} - #[cfg(feature = "mtrace")] fn setup() { use fastrace::collector::Config; @@ -384,7 +346,7 @@ fn setup() { fastrace::set_reporter(reporter, Config::default().report_interval(Duration::from_millis(1))); } -#[cfg(not(any(feature = "tokio-console", feature = "trace", feature = "mtrace")))] +#[cfg(not(any(feature = "tokio-console", feature = "mtrace")))] fn setup() { use tracing_subscriber::{prelude::*, EnvFilter}; diff --git a/foyer-common/src/code.rs b/foyer-common/src/code.rs index 8e94ee65..ae4826e6 100644 --- a/foyer-common/src/code.rs +++ b/foyer-common/src/code.rs @@ -24,12 +24,10 @@ pub trait Value: Send + Sync + 'static {} impl Key for T {} impl Value for T {} -// TODO(MrCroxx): use `expect` after `lint_reasons` is stable. /// Key trait for the disk cache. pub trait StorageKey: Key + Serialize + DeserializeOwned {} impl StorageKey for T where T: Key + Serialize + DeserializeOwned {} -// TODO(MrCroxx): use `expect` after `lint_reasons` is stable. /// Value trait for the disk cache. pub trait StorageValue: Value + 'static + Serialize + DeserializeOwned {} impl StorageValue for T where T: Value + Serialize + DeserializeOwned {} diff --git a/foyer-common/src/event.rs b/foyer-common/src/event.rs index 9161ed9e..0c76edd9 100644 --- a/foyer-common/src/event.rs +++ b/foyer-common/src/event.rs @@ -22,9 +22,8 @@ pub trait EventListener: Send + Sync + 'static { /// Associated value type. type Value; - // TODO(MrCroxx): use `expect` after `lint_reasons` is stable. - #[allow(unused_variables)] /// Called when a cache entry is released from the in-memory cache. + #[expect(unused_variables)] fn on_memory_release(&self, key: Self::Key, value: Self::Value) where Self::Key: Key, diff --git a/foyer-common/src/lib.rs b/foyer-common/src/lib.rs index 68479e8c..208d9ee1 100644 --- a/foyer-common/src/lib.rs +++ b/foyer-common/src/lib.rs @@ -13,6 +13,7 @@ // limitations under the License. #![warn(missing_docs)] +#![warn(clippy::allow_attributes)] //! Shared components and utils for foyer. diff --git a/foyer-common/src/metrics.rs b/foyer-common/src/metrics.rs index f1f81132..0544551d 100644 --- a/foyer-common/src/metrics.rs +++ b/foyer-common/src/metrics.rs @@ -16,69 +16,115 @@ use std::fmt::Debug; use metrics::{counter, gauge, histogram, Counter, Gauge, Histogram}; -// TODO(MrCroxx): use `expect` after `lint_reasons` is stable. -#[allow(missing_docs)] +// FIXME: https://github.com/rust-lang/rust-analyzer/issues/17685 +// #[expect(missing_docs)] +/// ... ... #[derive(Clone)] pub struct Metrics { /* in-memory cache metrics */ + /// ... ... pub memory_insert: Counter, + /// ... ... pub memory_replace: Counter, + /// ... ... pub memory_hit: Counter, + /// ... ... pub memory_miss: Counter, + /// ... ... pub memory_remove: Counter, + /// ... ... pub memory_evict: Counter, + /// ... ... pub memory_reinsert: Counter, + /// ... ... pub memory_release: Counter, + /// ... ... pub memory_queue: Counter, + /// ... ... pub memory_fetch: Counter, + /// ... ... pub memory_usage: Gauge, /* disk cache metrics */ + /// ... ... pub storage_enqueue: Counter, + /// ... ... pub storage_hit: Counter, + /// ... ... pub storage_miss: Counter, + /// ... ... pub storage_delete: Counter, + /// ... ... pub storage_enqueue_duration: Histogram, + /// ... ... pub storage_hit_duration: Histogram, + /// ... ... pub storage_miss_duration: Histogram, + /// ... ... pub storage_delete_duration: Histogram, + /// ... ... pub storage_queue_rotate: Counter, + /// ... ... pub storage_queue_rotate_duration: Histogram, + /// ... ... pub storage_queue_drop: Counter, + /// ... ... pub storage_disk_write: Counter, + /// ... ... pub storage_disk_read: Counter, + /// ... ... pub storage_disk_flush: Counter, + /// ... ... pub storage_disk_write_bytes: Counter, + /// ... ... pub storage_disk_read_bytes: Counter, + /// ... ... pub storage_disk_write_duration: Histogram, + /// ... ... pub storage_disk_read_duration: Histogram, + /// ... ... pub storage_disk_flush_duration: Histogram, + /// ... ... pub storage_region_total: Gauge, + /// ... ... pub storage_region_clean: Gauge, + /// ... ... pub storage_region_evictable: Gauge, + /// ... ... pub storage_region_size_bytes: Gauge, + /// ... ... pub storage_entry_serialize_duration: Histogram, + /// ... ... pub storage_entry_deserialize_duration: Histogram, /* hybrid cache metrics */ + /// ... ... pub hybrid_insert: Counter, + /// ... ... pub hybrid_hit: Counter, + /// ... ... pub hybrid_miss: Counter, + /// ... ... pub hybrid_remove: Counter, + /// ... ... pub hybrid_insert_duration: Histogram, + /// ... ... pub hybrid_hit_duration: Histogram, + /// ... ... pub hybrid_miss_duration: Histogram, + /// ... ... pub hybrid_remove_duration: Histogram, + /// ... ... pub hybrid_fetch_duration: Histogram, } diff --git a/foyer-intrusive/src/lib.rs b/foyer-intrusive/src/lib.rs index aa44c7f2..bf64ea7f 100644 --- a/foyer-intrusive/src/lib.rs +++ b/foyer-intrusive/src/lib.rs @@ -12,9 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -// TODO(MrCroxx): use `expect` after `lint_reasons` is stable. -#![allow(clippy::new_without_default)] +#![expect(clippy::new_without_default)] #![warn(missing_docs)] +#![warn(clippy::allow_attributes)] //! Intrusive data structures and utils for foyer. diff --git a/foyer-memory/src/eviction/s3fifo.rs b/foyer-memory/src/eviction/s3fifo.rs index e3aca1b9..1ae5d601 100644 --- a/foyer-memory/src/eviction/s3fifo.rs +++ b/foyer-memory/src/eviction/s3fifo.rs @@ -175,8 +175,7 @@ where self.evict_small_force() } - // TODO(MrCroxx): FIX ME!!! clippy false positive - #[allow(clippy::never_loop)] + #[expect(clippy::never_loop)] unsafe fn evict_small_force(&mut self) -> Option>> { while let Some(mut ptr) = self.small_queue.pop_front() { let handle = ptr.as_mut(); @@ -267,8 +266,6 @@ where handle.base_mut().set_in_eviction(true); } - // TODO: FIX ME! clippy false positive - // #[allow(clippy::never_loop)] unsafe fn pop(&mut self) -> Option> { if let Some(mut ptr) = self.evict() { let handle = ptr.as_mut(); diff --git a/foyer-memory/src/eviction/test_utils.rs b/foyer-memory/src/eviction/test_utils.rs index c83fd339..dd3f1f6f 100644 --- a/foyer-memory/src/eviction/test_utils.rs +++ b/foyer-memory/src/eviction/test_utils.rs @@ -15,8 +15,6 @@ use super::Eviction; use crate::handle::Handle; -// TODO(MrCroxx): use `expect` after `lint_reasons` is stable. -#[allow(clippy::type_complexity)] pub trait TestEviction: Eviction where Self::Handle: Handle, diff --git a/foyer-memory/src/generic.rs b/foyer-memory/src/generic.rs index 3da8bc94..8f20b089 100644 --- a/foyer-memory/src/generic.rs +++ b/foyer-memory/src/generic.rs @@ -64,8 +64,7 @@ struct SharedState { event_listener: Option>>, } -// TODO(MrCroxx): use `expect` after `lint_reasons` is stable. -#[allow(clippy::type_complexity)] +#[expect(clippy::type_complexity)] struct GenericCacheShard where K: Key, @@ -115,9 +114,8 @@ where } /// Insert a new entry into the cache. The handle for the new entry is returned. - // TODO(MrCroxx): use `expect` after `lint_reasons` is stable. - #[allow(clippy::type_complexity)] - #[allow(clippy::too_many_arguments)] + + #[expect(clippy::too_many_arguments)] #[fastrace::trace(name = "foyer::memory::generic::shard::emplace")] unsafe fn emplace( &mut self, @@ -241,8 +239,6 @@ where } /// Clear all cache entries. - // TODO(MrCroxx): use `expect` after `lint_reasons` is stable. - #[allow(clippy::type_complexity)] unsafe fn clear(&mut self, to_release: &mut Vec<(K, V, ::Context, usize)>) { // TODO(MrCroxx): Avoid collecting here? let ptrs = self.indexer.drain().collect_vec(); @@ -269,8 +265,6 @@ where } } - // TODO(MrCroxx): use `expect` after `lint_reasons` is stable. - #[allow(clippy::type_complexity)] #[fastrace::trace(name = "foyer::memory::generic::shard::evict")] unsafe fn evict(&mut self, weight: usize, to_release: &mut Vec<(K, V, ::Context, usize)>) { // TODO(MrCroxx): Use `let_chains` here after it is stable. @@ -292,8 +286,6 @@ where /// Release a handle used by an external user. /// /// Return `Some(..)` if the handle is released, or `None` if the handle is still in use. - // TODO(MrCroxx): use `expect` after `lint_reasons` is stable. - #[allow(clippy::type_complexity)] unsafe fn try_release_external_handle( &mut self, mut ptr: NonNull, @@ -307,8 +299,6 @@ where /// Return the entry if the handle is released. /// /// Recycle it if possible. - // TODO(MrCroxx): use `expect` after `lint_reasons` is stable. - #[allow(clippy::type_complexity)] unsafe fn try_release_handle( &mut self, mut ptr: NonNull, @@ -473,8 +463,7 @@ where } } -// TODO(MrCroxx): use `expect` after `lint_reasons` is stable. -#[allow(clippy::type_complexity)] +#[expect(clippy::type_complexity)] pub struct GenericCache where K: Key, @@ -1015,8 +1004,7 @@ mod tests { is_send_sync_static::>(); } - // TODO(MrCroxx): use `expect` after `lint_reasons` is stable. - #[allow(clippy::type_complexity)] + #[expect(clippy::type_complexity)] fn fuzzy(cache: Arc>>>) where E: Eviction, diff --git a/foyer-memory/src/lib.rs b/foyer-memory/src/lib.rs index f0cb72b6..cf3e2fe3 100644 --- a/foyer-memory/src/lib.rs +++ b/foyer-memory/src/lib.rs @@ -63,6 +63,7 @@ //! destroyed. #![warn(missing_docs)] +#![warn(clippy::allow_attributes)] mod cache; mod context; diff --git a/foyer-storage/src/engine.rs b/foyer-storage/src/engine.rs index d8d66b86..51357acd 100644 --- a/foyer-storage/src/engine.rs +++ b/foyer-storage/src/engine.rs @@ -101,8 +101,6 @@ enum StoreFuture { } impl StoreFuture { - // TODO(MrCroxx): use `expect` after `lint_reasons` is stable. - #[allow(clippy::type_complexity)] pub fn as_pin_mut(self: Pin<&mut Self>) -> StoreFuture, Pin<&mut F2>, Pin<&mut F3>, Pin<&mut F4>> { unsafe { match *Pin::get_unchecked_mut(self) { @@ -134,8 +132,7 @@ where } } -// TODO(MrCroxx): use `expect` after `lint_reasons` is stable. -#[allow(clippy::type_complexity)] +#[expect(clippy::type_complexity)] pub enum EngineConfig where K: StorageKey, @@ -164,8 +161,7 @@ where } } -// TODO(MrCroxx): use `expect` after `lint_reasons` is stable. -#[allow(clippy::type_complexity)] +#[expect(clippy::type_complexity)] pub enum Engine where K: StorageKey, diff --git a/foyer-storage/src/large/flusher.rs b/foyer-storage/src/large/flusher.rs index af523dfe..4572bc14 100644 --- a/foyer-storage/src/large/flusher.rs +++ b/foyer-storage/src/large/flusher.rs @@ -104,8 +104,7 @@ where V: StorageValue, S: HashBuilder + Debug, { - // TODO(MrCroxx): use `expect` after `lint_reasons` is stable. - #[allow(clippy::too_many_arguments)] + #[expect(clippy::too_many_arguments)] pub async fn open( config: &GenericLargeStorageConfig, indexer: Indexer, diff --git a/foyer-storage/src/large/reclaimer.rs b/foyer-storage/src/large/reclaimer.rs index d32c765b..b7a6b249 100644 --- a/foyer-storage/src/large/reclaimer.rs +++ b/foyer-storage/src/large/reclaimer.rs @@ -46,8 +46,7 @@ pub struct Reclaimer { } impl Reclaimer { - // TODO(MrCroxx): use `expect` after `lint_reasons` is stable. - #[allow(clippy::too_many_arguments)] + #[expect(clippy::too_many_arguments)] pub async fn open( region_manager: RegionManager, reclaim_semaphore: Arc, diff --git a/foyer-storage/src/large/recover.rs b/foyer-storage/src/large/recover.rs index d5f0ac1b..74ed3bcb 100644 --- a/foyer-storage/src/large/recover.rs +++ b/foyer-storage/src/large/recover.rs @@ -63,8 +63,7 @@ pub enum RecoverMode { pub struct RecoverRunner; impl RecoverRunner { - // TODO(MrCroxx): use `expect` after `lint_reasons` is stable. - #[allow(clippy::too_many_arguments)] + #[expect(clippy::too_many_arguments)] pub async fn run( config: &GenericLargeStorageConfig, regions: Range, diff --git a/foyer-storage/src/large/scanner.rs b/foyer-storage/src/large/scanner.rs index f735f26c..ce5eeb08 100644 --- a/foyer-storage/src/large/scanner.rs +++ b/foyer-storage/src/large/scanner.rs @@ -183,8 +183,7 @@ impl RegionScanner { Ok(Some((info, key))) } - // TODO(MrCroxx): use `expect` after `lint_reasons` is stable. - #[allow(dead_code)] + #[expect(dead_code)] pub async fn next_value(&mut self) -> Result> where V: StorageValue, @@ -207,8 +206,7 @@ impl RegionScanner { Ok(Some((info, value))) } - // TODO(MrCroxx): use `expect` after `lint_reasons` is stable. - #[allow(dead_code)] + #[expect(dead_code)] pub async fn next_kv(&mut self) -> Result> where K: StorageKey, diff --git a/foyer-storage/src/lib.rs b/foyer-storage/src/lib.rs index b30d05c3..14d081e7 100644 --- a/foyer-storage/src/lib.rs +++ b/foyer-storage/src/lib.rs @@ -16,6 +16,7 @@ #![cfg_attr(feature = "nightly", feature(allocator_api))] #![warn(missing_docs)] +#![warn(clippy::allow_attributes)] mod compress; mod device; diff --git a/foyer-storage/src/picker/mod.rs b/foyer-storage/src/picker/mod.rs index 98ff6f43..8cec22df 100644 --- a/foyer-storage/src/picker/mod.rs +++ b/foyer-storage/src/picker/mod.rs @@ -37,8 +37,7 @@ pub trait ReinsertionPicker: Send + Sync + 'static + Debug { /// The eviction picker for the disk cache. pub trait EvictionPicker: Send + Sync + 'static + Debug { /// Init the eviction picker with information. - // TODO(MrCroxx): use `expect` after `lint_reasons` is stable. - #[allow(unused_variables)] + #[expect(unused_variables)] fn init(&mut self, regions: usize, region_size: usize) {} /// Pick a region to evict. diff --git a/foyer-storage/src/region.rs b/foyer-storage/src/region.rs index 130bfa35..6046bab6 100644 --- a/foyer-storage/src/region.rs +++ b/foyer-storage/src/region.rs @@ -288,14 +288,12 @@ impl RegionManager { self.inner.regions.len() } - // TODO(MrCroxx): use `expect` after `lint_reasons` is stable. - #[allow(dead_code)] + #[expect(dead_code)] pub fn evictable_regions(&self) -> usize { self.inner.eviction.lock().evictable.len() } - // TODO(MrCroxx): use `expect` after `lint_reasons` is stable. - #[allow(dead_code)] + #[expect(dead_code)] pub fn clean_regions(&self) -> usize { self.inner.clean_region_rx.len() } diff --git a/foyer-storage/src/serde.rs b/foyer-storage/src/serde.rs index fcc805cb..89642226 100644 --- a/foyer-storage/src/serde.rs +++ b/foyer-storage/src/serde.rs @@ -47,7 +47,6 @@ pub struct KvInfo { pub struct EntrySerializer; impl EntrySerializer { - #[allow(clippy::needless_borrows_for_generic_args)] #[fastrace::trace(name = "foyer::storage::serde::serialize")] pub fn serialize<'a, K, V>( key: &'a K, diff --git a/foyer-storage/src/small/generic.rs b/foyer-storage/src/small/generic.rs index d7e6a983..cd086bc1 100644 --- a/foyer-storage/src/small/generic.rs +++ b/foyer-storage/src/small/generic.rs @@ -94,9 +94,7 @@ where todo!() } - // FIXME: REMOVE THE CLIPPY IGNORE. - // TODO(MrCroxx): use `expect` after `lint_reasons` is stable. - #[allow(clippy::manual_async_fn)] + #[expect(clippy::manual_async_fn)] fn load(&self, _hash: u64) -> impl Future>> + Send + 'static { async { todo!() } } @@ -115,9 +113,7 @@ where todo!() } - // TODO(MrCroxx): Remove the attr after impl. - // TODO(MrCroxx): use `expect` after `lint_reasons` is stable. - #[allow(clippy::manual_async_fn)] + #[expect(clippy::manual_async_fn)] fn wait(&self) -> impl Future + Send + 'static { async { todo!() } } diff --git a/foyer-storage/src/storage/either.rs b/foyer-storage/src/storage/either.rs index cdc64417..8708f453 100644 --- a/foyer-storage/src/storage/either.rs +++ b/foyer-storage/src/storage/either.rs @@ -35,8 +35,6 @@ enum OrderFuture { } impl OrderFuture { - // TODO(MrCroxx): use `expect` after `lint_reasons` is stable. - #[allow(clippy::type_complexity)] pub fn as_pin_mut(self: Pin<&mut Self>) -> OrderFuture, Pin<&mut F2>, Pin<&mut F3>> { unsafe { match *Pin::get_unchecked_mut(self) { diff --git a/foyer-storage/src/storage/mod.rs b/foyer-storage/src/storage/mod.rs index bbaba9a4..f3f56f49 100644 --- a/foyer-storage/src/storage/mod.rs +++ b/foyer-storage/src/storage/mod.rs @@ -23,8 +23,6 @@ use foyer_memory::CacheEntry; use crate::{device::monitor::DeviceStats, error::Result, serde::KvInfo, IoBytes}; /// The storage trait for the disk cache storage engine. -// TODO(MrCroxx): Remove this after in-memory cache event listener is removed. -#[allow(clippy::type_complexity)] pub trait Storage: Send + Sync + 'static + Clone + Debug { /// Disk cache key type. type Key: StorageKey; diff --git a/foyer-storage/tests/storage_test.rs b/foyer-storage/tests/storage_test.rs index a0a44fd3..e7983577 100644 --- a/foyer-storage/tests/storage_test.rs +++ b/foyer-storage/tests/storage_test.rs @@ -12,8 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// TODO(MrCroxx): use `expect` after `lint_reasons` is stable. -#![allow(clippy::identity_op)] +#![expect(clippy::identity_op)] use std::{path::Path, sync::Arc, time::Duration}; diff --git a/foyer-util/src/compact_bloom_filter.rs b/foyer-util/src/compact_bloom_filter.rs index 43c4c4f4..103244f5 100644 --- a/foyer-util/src/compact_bloom_filter.rs +++ b/foyer-util/src/compact_bloom_filter.rs @@ -117,8 +117,7 @@ impl CompactBloomFilter { /// /// See [`CompactBloomFilterShard`]. pub fn shards(filters: usize, hashes: usize, bits: usize) -> Vec { - // TODO(MrCroxx): use `expect` after `lint_reasons` is stable. - #[allow(clippy::arc_with_non_send_sync)] + #[expect(clippy::arc_with_non_send_sync)] let filter = Arc::new(UnsafeCell::new(Self::new(filters, hashes, bits))); (0..filters) .map(|idx| CompactBloomFilterShard { diff --git a/foyer-util/src/iostat.rs b/foyer-util/src/iostat.rs index 28857701..cc88e8e1 100644 --- a/foyer-util/src/iostat.rs +++ b/foyer-util/src/iostat.rs @@ -34,8 +34,6 @@ use itertools::Itertools; #[cfg(unix)] use nix::{fcntl::readlink, sys::stat::stat}; -// TODO(MrCroxx): use `expect` after `lint_reasons` is stable. -#[cfg_attr(not(target_os = "linux"), allow(dead_code))] #[derive(PartialEq, Clone, Copy, Debug)] pub enum FsType { Xfs, @@ -45,8 +43,7 @@ pub enum FsType { Others, } -// TODO(MrCroxx): use `expect` after `lint_reasons` is stable. -#[cfg_attr(not(target_os = "linux"), allow(unused_variables))] +#[cfg_attr(not(target_os = "linux"), expect(unused_variables))] pub fn detect_fs_type(path: impl AsRef) -> FsType { #[cfg(target_os = "linux")] { diff --git a/foyer-util/src/lib.rs b/foyer-util/src/lib.rs index 85317159..05d4f02d 100644 --- a/foyer-util/src/lib.rs +++ b/foyer-util/src/lib.rs @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#![warn(clippy::allow_attributes)] + pub mod batch; pub mod compact_bloom_filter; pub mod continuum; diff --git a/foyer/Cargo.toml b/foyer/Cargo.toml index b0854039..fecd526a 100644 --- a/foyer/Cargo.toml +++ b/foyer/Cargo.toml @@ -8,7 +8,7 @@ license = "Apache-2.0" repository = "https://github.com/foyer-rs/foyer" homepage = "https://github.com/foyer-rs/foyer" readme = "../README.md" -rust-version = "1.77" +rust-version = "1.81.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] diff --git a/foyer/src/hybrid/cache.rs b/foyer/src/hybrid/cache.rs index e132d982..9baf52c1 100644 --- a/foyer/src/hybrid/cache.rs +++ b/foyer/src/hybrid/cache.rs @@ -211,7 +211,7 @@ where pub async fn get(&self, key: &Q) -> anyhow::Result>> where K: Borrow, - Q: Hash + Eq + ?Sized + Send + Sync + 'static + Clone, + Q: Hash + Eq + Send + Sync + 'static + Clone, { root_span!(self, mut span, "foyer::hybrid::cache::get"); diff --git a/foyer/src/lib.rs b/foyer/src/lib.rs index 56085d53..dc0710cd 100644 --- a/foyer/src/lib.rs +++ b/foyer/src/lib.rs @@ -14,6 +14,7 @@ #![cfg_attr(feature = "nightly", feature(allocator_api))] #![warn(missing_docs)] +#![warn(clippy::allow_attributes)] //! A hybrid cache library that supports plug-and-play cache algorithms, in-memory cache and disk cache.