From e2bf065fdc30ca4564954179f2fede9d955a7987 Mon Sep 17 00:00:00 2001 From: Adam Reichold Date: Sat, 4 May 2024 10:32:33 +0200 Subject: [PATCH] Make current Clippy happy --- build.rs | 2 ++ src/db.rs | 1 + src/transactions.rs | 8 ++++---- src/tree_store/page_store/buddy_allocator.rs | 2 +- src/tree_store/page_store/cached_file.rs | 8 ++++---- src/tree_store/page_store/page_manager.rs | 4 ++-- 6 files changed, 14 insertions(+), 11 deletions(-) diff --git a/build.rs b/build.rs index 76f9c70b..b699ccb3 100644 --- a/build.rs +++ b/build.rs @@ -1,4 +1,6 @@ fn main() { + println!("cargo:rustc-check-cfg=cfg(fuzzing)"); + if std::env::var("CARGO_CFG_FUZZING").is_ok() && std::env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("macos") { diff --git a/src/db.rs b/src/db.rs index 3dbdc34e..d418b751 100644 --- a/src/db.rs +++ b/src/db.rs @@ -933,6 +933,7 @@ impl Builder { .read(true) .write(true) .create(true) + .truncate(false) .open(path)?; Database::new( diff --git a/src/transactions.rs b/src/transactions.rs index b7629666..b60b8b8a 100644 --- a/src/transactions.rs +++ b/src/transactions.rs @@ -386,9 +386,9 @@ impl<'db> TableNamespace<'db> { } #[track_caller] - fn delete_table<'txn>( + fn delete_table( &mut self, - transaction: &'txn WriteTransaction, + transaction: &WriteTransaction, name: &str, ) -> Result { #[cfg(feature = "logging")] @@ -398,9 +398,9 @@ impl<'db> TableNamespace<'db> { } #[track_caller] - fn delete_multimap_table<'txn>( + fn delete_multimap_table( &mut self, - transaction: &'txn WriteTransaction, + transaction: &WriteTransaction, name: &str, ) -> Result { #[cfg(feature = "logging")] diff --git a/src/tree_store/page_store/buddy_allocator.rs b/src/tree_store/page_store/buddy_allocator.rs index 4d98ec5d..6f81b4a2 100644 --- a/src/tree_store/page_store/buddy_allocator.rs +++ b/src/tree_store/page_store/buddy_allocator.rs @@ -164,7 +164,7 @@ impl BuddyAllocator { pub(crate) fn count_free_pages(&self) -> u32 { let mut pages = 0; for order in 0..=self.max_order { - pages += self.get_order_free(order).count_unset() * 2u32.pow(order.try_into().unwrap()); + pages += self.get_order_free(order).count_unset() * 2u32.pow(order.into()); } pages } diff --git a/src/tree_store/page_store/cached_file.rs b/src/tree_store/page_store/cached_file.rs index b2cd6ab4..afd0348c 100644 --- a/src/tree_store/page_store/cached_file.rs +++ b/src/tree_store/page_store/cached_file.rs @@ -90,10 +90,10 @@ impl PrioritizedCache { priority: CachePriority, ) -> Option>> { if matches!(priority, CachePriority::Low) { - debug_assert!(self.cache.get(&key).is_none()); + debug_assert!(!self.cache.contains_key(&key)); self.low_pri_cache.insert(key, value) } else { - debug_assert!(self.low_pri_cache.get(&key).is_none()); + debug_assert!(!self.low_pri_cache.contains_key(&key)); self.cache.insert(key, value) } } @@ -140,10 +140,10 @@ impl PrioritizedWriteCache { fn insert(&mut self, key: u64, value: Arc>, priority: CachePriority) { if matches!(priority, CachePriority::Low) { assert!(self.low_pri_cache.insert(key, Some(value)).is_none()); - debug_assert!(self.cache.get(&key).is_none()); + debug_assert!(!self.cache.contains_key(&key)); } else { assert!(self.cache.insert(key, Some(value)).is_none()); - debug_assert!(self.low_pri_cache.get(&key).is_none()); + debug_assert!(!self.low_pri_cache.contains_key(&key)); } } diff --git a/src/tree_store/page_store/page_manager.rs b/src/tree_store/page_store/page_manager.rs index e38478a1..cfd48feb 100644 --- a/src/tree_store/page_store/page_manager.rs +++ b/src/tree_store/page_store/page_manager.rs @@ -946,8 +946,8 @@ impl TransactionalMemory { fn grow(&self, state: &mut InMemoryState, required_order_allocation: u8) -> Result<()> { let layout = state.header.layout(); - let required_growth = 2u64.pow(required_order_allocation.try_into().unwrap()) - * state.header.page_size() as u64; + let required_growth = + 2u64.pow(required_order_allocation.into()) * state.header.page_size() as u64; let max_region_size = (state.header.layout().full_region_layout().num_pages() as u64) * (state.header.page_size() as u64); let next_desired_size = if layout.num_full_regions() > 0 {