fix clippy (#1737)

This commit is contained in:
Carl Lerche
2019-11-05 23:38:52 -08:00
committed by GitHub
parent d5c1119c88
commit 0da23aad77
7 changed files with 26 additions and 23 deletions
+1 -1
View File
@@ -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
+5
View File
@@ -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 {
+1 -1
View File
@@ -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
+2
View File
@@ -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(
-6
View File
@@ -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() {
+1 -2
View File
@@ -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))
}
}
+16 -13
View File
@@ -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,