Skip to content

Commit

Permalink
Fix Clippy and compiler warnings
Browse files Browse the repository at this point in the history
- Fix beta Clippy warnings
  - clippy 0.1.77 (f2048098a1c 2024-02-09)
- Fix beta compiler warnings
  - rustc 1.77.0-beta.2 (f2048098a 2024-02-09)
  • Loading branch information
tatsuya6502 committed Feb 10, 2024
1 parent 6fb0e82 commit 13d45b3
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 11 deletions.
12 changes: 10 additions & 2 deletions src/common/timer_wheel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,10 +401,13 @@ pub(crate) enum TimerEvent<K> {
// 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<EntryInfo<K>>),
#[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<DeqNode<TimerNode<K>>>),
Descheduled,
}

/// An iterator over expired cache entries.
Expand Down Expand Up @@ -515,18 +518,23 @@ 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();
return Some(TimerEvent::Rescheduled(TrioArc::clone(
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);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/future/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> = Result<T, Arc<MyError>>;

Expand Down Expand Up @@ -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<T> = Result<T, Arc<MyError>>;

Expand Down
4 changes: 2 additions & 2 deletions src/policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ impl<K, V> Clone for ExpirationPolicy<K, V> {
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(),
}
}
}
Expand Down Expand Up @@ -244,7 +244,7 @@ impl<K, V> ExpirationPolicy<K, V> {
}

pub(crate) fn expiry(&self) -> Option<Arc<dyn Expiry<K, V> + Send + Sync + 'static>> {
self.expiry.as_ref().map(Arc::clone)
self.expiry.clone()
}

pub(crate) fn set_expiry(&mut self, expiry: Arc<dyn Expiry<K, V> + Send + Sync + 'static>) {
Expand Down
4 changes: 2 additions & 2 deletions src/sync/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> = Result<T, Arc<MyError>>;

Expand Down Expand Up @@ -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<T> = Result<T, Arc<MyError>>;

Expand Down
4 changes: 2 additions & 2 deletions src/sync/segment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/sync_base/base_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl<K, V, S> Clone for BaseCache<K, V, S> {
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(),
}
}
}
Expand Down

0 comments on commit 13d45b3

Please sign in to comment.