diff --git a/src/common/timer_wheel.rs b/src/common/timer_wheel.rs index 6badd648..ed6985dc 100644 --- a/src/common/timer_wheel.rs +++ b/src/common/timer_wheel.rs @@ -401,10 +401,13 @@ pub(crate) enum TimerEvent { // This cache entry has been rescheduled. Rescheduling includes moving a timer // from one wheel to another in a lower level of the hierarchy. (This variant // is mainly used for testing) + #[cfg(test)] Rescheduled(TrioArc>), + #[cfg(not(test))] + Rescheduled(()), /// This timer node (containing a cache entry) has been removed from the timer. /// (This variant is mainly used for testing) - Descheduled(Box>>), + Descheduled, } /// An iterator over expired cache entries. @@ -515,6 +518,7 @@ impl<'iter, K> Iterator for TimerEventsIter<'iter, K> { // The cache entry has not expired. Reschedule it. let node_p = NonNull::new(Box::into_raw(node)).expect("Got a null ptr"); match self.timer_wheel.schedule_existing_node(node_p) { + #[cfg(test)] ReschedulingResult::Rescheduled => { let entry_info = unsafe { node_p.as_ref() }.element.entry_info(); @@ -522,11 +526,15 @@ impl<'iter, K> Iterator for TimerEventsIter<'iter, K> { entry_info, ))); } + #[cfg(not(test))] + ReschedulingResult::Rescheduled => { + return Some(TimerEvent::Rescheduled(())); + } ReschedulingResult::Removed(node) => { // The timer event has been removed from the timer // wheel. Unset the timer node from the ValueEntry. node.as_ref().element.unset_timer_node_in_deq_nodes(); - return Some(TimerEvent::Descheduled(node)); + return Some(TimerEvent::Descheduled); } } } diff --git a/src/future/cache.rs b/src/future/cache.rs index 4d783abb..90044b92 100644 --- a/src/future/cache.rs +++ b/src/future/cache.rs @@ -3578,7 +3578,7 @@ mod tests { // Note that MyError does not implement std::error::Error trait // like anyhow::Error. #[derive(Debug)] - pub struct MyError(String); + pub struct MyError(#[allow(dead_code)] String); type MyResult = Result>; @@ -3713,7 +3713,7 @@ mod tests { // Note that MyError does not implement std::error::Error trait // like anyhow::Error. #[derive(Debug)] - pub struct MyError(String); + pub struct MyError(#[allow(dead_code)] String); type MyResult = Result>; diff --git a/src/policy.rs b/src/policy.rs index 155ec3da..ce91b76c 100644 --- a/src/policy.rs +++ b/src/policy.rs @@ -206,7 +206,7 @@ impl Clone for ExpirationPolicy { Self { time_to_live: self.time_to_live, time_to_idle: self.time_to_idle, - expiry: self.expiry.as_ref().map(Arc::clone), + expiry: self.expiry.clone(), } } } @@ -244,7 +244,7 @@ impl ExpirationPolicy { } pub(crate) fn expiry(&self) -> Option + Send + Sync + 'static>> { - self.expiry.as_ref().map(Arc::clone) + self.expiry.clone() } pub(crate) fn set_expiry(&mut self, expiry: Arc + Send + Sync + 'static>) { diff --git a/src/sync/cache.rs b/src/sync/cache.rs index 2e3dd2c2..c47245dc 100644 --- a/src/sync/cache.rs +++ b/src/sync/cache.rs @@ -3588,7 +3588,7 @@ mod tests { // Note that MyError does not implement std::error::Error trait like // anyhow::Error. #[derive(Debug)] - pub struct MyError(String); + pub struct MyError(#[allow(dead_code)] String); type MyResult = Result>; @@ -3727,7 +3727,7 @@ mod tests { // Note that MyError does not implement std::error::Error trait like // anyhow::Error. #[derive(Debug)] - pub struct MyError(String); + pub struct MyError(#[allow(dead_code)] String); type MyResult = Result>; diff --git a/src/sync/segment.rs b/src/sync/segment.rs index c1728ad3..166ff5a3 100644 --- a/src/sync/segment.rs +++ b/src/sync/segment.rs @@ -759,8 +759,8 @@ where seg_max_capacity, seg_init_capacity, build_hasher.clone(), - weigher.as_ref().map(Arc::clone), - eviction_listener.as_ref().map(Arc::clone), + weigher.clone(), + eviction_listener.clone(), eviction_listener_conf.clone(), expiration_policy.clone(), invalidator_enabled, diff --git a/src/sync_base/base_cache.rs b/src/sync_base/base_cache.rs index 7dd68220..08638ce8 100644 --- a/src/sync_base/base_cache.rs +++ b/src/sync_base/base_cache.rs @@ -74,7 +74,7 @@ impl Clone for BaseCache { inner: Arc::clone(&self.inner), read_op_ch: self.read_op_ch.clone(), write_op_ch: self.write_op_ch.clone(), - housekeeper: self.housekeeper.as_ref().map(Arc::clone), + housekeeper: self.housekeeper.clone(), } } }