mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-16 00:00:12 +02:00
fix clippy (#1737)
This commit is contained in:
+1
-1
@@ -12,5 +12,5 @@ jobs:
|
||||
cargo clippy --version
|
||||
displayName: Install clippy
|
||||
- script: |
|
||||
cargo clippy --all --all-features -- -A clippy::mutex-atomic
|
||||
cargo clippy --all --all-features -- -A clippy::mutex-atomic -A clippy::needless-doctest-main
|
||||
displayName: cargo clippy --all
|
||||
|
||||
@@ -57,6 +57,11 @@ pub trait AsyncRead {
|
||||
///
|
||||
/// This function is called from [`poll_read_buf`].
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// Implementations that return `false` must never read from data slices
|
||||
/// that they did not write to.
|
||||
///
|
||||
/// [`io::Read`]: std::io::Read
|
||||
/// [`poll_read_buf`]: #method.poll_read_buf
|
||||
unsafe fn prepare_uninitialized_buffer(&self, buf: &mut [u8]) -> bool {
|
||||
|
||||
@@ -479,7 +479,7 @@ impl Command {
|
||||
/// will be called and the spawn operation will immediately return with a
|
||||
/// failure.
|
||||
///
|
||||
/// # Notes and Safety
|
||||
/// # Safety
|
||||
///
|
||||
/// This closure will be run in the context of the child process after a
|
||||
/// `fork`. This primarily means that any modifications made to memory on
|
||||
|
||||
@@ -337,6 +337,8 @@ impl fmt::Debug for Scheduler {
|
||||
|
||||
unsafe fn sched_clone_waker(ptr: *const ()) -> RawWaker {
|
||||
let s1 = ManuallyDrop::new(Arc::from_raw(ptr as *const Scheduler));
|
||||
|
||||
#[allow(clippy::redundant_clone)]
|
||||
let s2 = s1.clone();
|
||||
|
||||
RawWaker::new(
|
||||
|
||||
@@ -358,8 +358,6 @@ where
|
||||
park: &mut impl Park<Unpark = P>,
|
||||
gone: &Cell<bool>,
|
||||
) -> Result<bool, WorkerGone> {
|
||||
debug_assert!(self.is_running());
|
||||
|
||||
loop {
|
||||
let tick = self.tick_fetch_inc();
|
||||
|
||||
@@ -412,8 +410,6 @@ where
|
||||
}
|
||||
|
||||
fn search_for_work(&mut self, gone: &Cell<bool>) -> Result<bool, WorkerGone> {
|
||||
debug_assert!(self.is_searching());
|
||||
|
||||
if let Some(task) = self.steal_work() {
|
||||
self.run_task(task, gone)?;
|
||||
Ok(true)
|
||||
@@ -435,8 +431,6 @@ where
|
||||
}
|
||||
|
||||
fn transition_from_searching(&mut self) {
|
||||
debug_assert!(self.is_searching());
|
||||
|
||||
self.owned().is_searching.set(false);
|
||||
|
||||
if self.set().idle().transition_worker_from_searching() {
|
||||
|
||||
@@ -298,7 +298,6 @@ impl<T: Clone> Receiver<T> {
|
||||
impl<T: Clone> futures_core::Stream for Receiver<T> {
|
||||
type Item = T;
|
||||
|
||||
#[allow(clippy::map_clone)] // false positive: https://github.com/rust-lang/rust-clippy/issues/3274
|
||||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<T>> {
|
||||
use std::future::Future;
|
||||
|
||||
@@ -306,7 +305,7 @@ impl<T: Clone> futures_core::Stream for Receiver<T> {
|
||||
pin_mut!(fut);
|
||||
|
||||
let item = ready!(fut.poll(cx));
|
||||
Ready(item.map(|v_ref| v_ref.clone()))
|
||||
Ready(item.map(|v_ref| v_ref))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -173,19 +173,7 @@ where
|
||||
if let Some(expiration) = self.levels[level].next_expiration(self.elapsed) {
|
||||
// There cannot be any expirations at a higher level that happen
|
||||
// before this one.
|
||||
debug_assert!({
|
||||
let mut res = true;
|
||||
|
||||
for l2 in (level + 1)..NUM_LEVELS {
|
||||
if let Some(e2) = self.levels[l2].next_expiration(self.elapsed) {
|
||||
if e2.deadline < expiration.deadline {
|
||||
res = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
res
|
||||
});
|
||||
debug_assert!(self.no_expirations_before(level + 1, expiration.deadline));
|
||||
|
||||
return Some(expiration);
|
||||
}
|
||||
@@ -194,6 +182,21 @@ where
|
||||
None
|
||||
}
|
||||
|
||||
/// Used for debug assertions
|
||||
fn no_expirations_before(&self, start_level: usize, before: u64) -> bool {
|
||||
let mut res = true;
|
||||
|
||||
for l2 in start_level..NUM_LEVELS {
|
||||
if let Some(e2) = self.levels[l2].next_expiration(self.elapsed) {
|
||||
if e2.deadline < before {
|
||||
res = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
res
|
||||
}
|
||||
|
||||
pub(crate) fn poll_expiration(
|
||||
&mut self,
|
||||
expiration: &Expiration,
|
||||
|
||||
Reference in New Issue
Block a user