From 268414b502eb70b6d7861320d7c84d1c318d2dbf Mon Sep 17 00:00:00 2001 From: Amanieu d'Antras Date: Wed, 19 Jun 2024 16:33:18 +0100 Subject: [PATCH] Fix clippy warnings --- src/map.rs | 1 - src/raw/mod.rs | 8 ++++---- tests/hasher.rs | 6 +++--- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/map.rs b/src/map.rs index 175d5adbd..a7f81debd 100644 --- a/src/map.rs +++ b/src/map.rs @@ -6718,7 +6718,6 @@ mod test_map { use rand::{rngs::SmallRng, Rng, SeedableRng}; use std::borrow::ToOwned; use std::cell::RefCell; - use std::usize; use std::vec::Vec; #[test] diff --git a/src/raw/mod.rs b/src/raw/mod.rs index db5384641..44221f7c9 100644 --- a/src/raw/mod.rs +++ b/src/raw/mod.rs @@ -1235,7 +1235,7 @@ impl RawTable { fallibility, Self::TABLE_LAYOUT, if T::NEEDS_DROP { - Some(mem::transmute(ptr::drop_in_place:: as unsafe fn(*mut T))) + Some(|ptr| ptr::drop_in_place(ptr as *mut T)) } else { None }, @@ -2911,7 +2911,7 @@ impl RawTableInner { hasher: &dyn Fn(&mut Self, usize) -> u64, fallibility: Fallibility, layout: TableLayout, - drop: Option, + drop: Option, ) -> Result<(), TryReserveError> where A: Allocator, @@ -3145,7 +3145,7 @@ impl RawTableInner { &mut self, hasher: &dyn Fn(&mut Self, usize) -> u64, size_of: usize, - drop: Option, + drop: Option, ) { // If the hash function panics then properly clean up any elements // that we haven't rehashed yet. We unfortunately can't preserve the @@ -4577,7 +4577,7 @@ mod test_map { &|table, index| hasher(table.bucket::(index).as_ref()), mem::size_of::(), if mem::needs_drop::() { - Some(mem::transmute(ptr::drop_in_place:: as unsafe fn(*mut T))) + Some(|ptr| ptr::drop_in_place(ptr as *mut T)) } else { None }, diff --git a/tests/hasher.rs b/tests/hasher.rs index f6920108b..223737844 100644 --- a/tests/hasher.rs +++ b/tests/hasher.rs @@ -11,13 +11,13 @@ fn check() { let mut set = HashSet::::default(); set.extend(range.clone()); - assert!(!set.contains(&i32::min_value())); + assert!(!set.contains(&i32::MIN)); assert!(!set.contains(&(range.start - 1))); for i in range.clone() { assert!(set.contains(&i)); } assert!(!set.contains(&range.end)); - assert!(!set.contains(&i32::max_value())); + assert!(!set.contains(&i32::MAX)); } /// Use hashbrown's default hasher. @@ -56,7 +56,7 @@ fn max() { impl Hasher for MaxHasher { fn finish(&self) -> u64 { - u64::max_value() + u64::MAX } fn write(&mut self, _: &[u8]) {} }