From 3aaa75824f397b5f038d2c5c676b7207d555eff9 Mon Sep 17 00:00:00 2001 From: Weijia Jiang Date: Thu, 28 Sep 2023 09:07:08 +0800 Subject: [PATCH] clippy fix --- .../src/runtime/scheduler/multi_thread_alt/worker.rs | 2 +- tokio/src/runtime/task/core.rs | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs b/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs index 1533546e807..f3b96c87c5a 100644 --- a/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs +++ b/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs @@ -1462,7 +1462,7 @@ impl Shared { pub(super) fn shutdown_core(&self, handle: &Handle, mut core: Box) { // Start from a random inner list - let start = core.rand.fastrand_n(self.owned.segment_size as u32); + let start = core.rand.fastrand_n(self.owned.segment_size); self.owned.close_and_shutdown_all(start as usize); core.stats.submit(&self.worker_metrics[core.index]); diff --git a/tokio/src/runtime/task/core.rs b/tokio/src/runtime/task/core.rs index 1adce2fcea7..3f275b2155d 100644 --- a/tokio/src/runtime/task/core.rs +++ b/tokio/src/runtime/task/core.rs @@ -403,8 +403,8 @@ impl Header { // the safety requirements on `set_owner_id`. unsafe { self.owner_id.with(|ptr| match *ptr { - Some(num) => return NonZeroU32::new((num.get() & 0xFFFF_FFFF) as u32), - None => return None, + Some(num) => NonZeroU32::new((num.get() & 0xFFFF_FFFF) as u32), + None => None, }) } } @@ -412,11 +412,8 @@ impl Header { pub(super) fn get_segment_id(&self) -> Option { // safety: If there are concurrent writes, then that write has violated // the safety requirements on `set_segment_id`. - unsafe { - self.owner_id.with(|ptr| match *ptr { - Some(num) => return Some((num.get() >> 32) as u32), - None => return None, - }) + unsafe { + self.owner_id.with(|ptr| (*ptr).map(|num| (num.get() >> 32) as u32)) } }