From 3bff5a3ffe68c7bbf94fc91a58633f5a91f4266c Mon Sep 17 00:00:00 2001 From: Artem Vorotnikov Date: Sat, 21 Dec 2019 00:54:43 +0300 Subject: chore: formatting, docs and clippy (#2000) --- tokio-macros/src/lib.rs | 1 + tokio-util/src/lib.rs | 1 + tokio/src/lib.rs | 2 +- tokio/src/stream/iter.rs | 6 ++++-- tokio/src/stream/map.rs | 22 ++++++++++------------ tokio/src/stream/mod.rs | 2 +- tokio/src/stream/next.rs | 5 +---- tokio/tests/rt_basic.rs | 2 +- tokio/tests/sync_broadcast.rs | 1 + tokio/tests/task_local_set.rs | 2 +- 10 files changed, 22 insertions(+), 22 deletions(-) diff --git a/tokio-macros/src/lib.rs b/tokio-macros/src/lib.rs index 58092ed9..1116735a 100644 --- a/tokio-macros/src/lib.rs +++ b/tokio-macros/src/lib.rs @@ -1,4 +1,5 @@ #![doc(html_root_url = "https://docs.rs/tokio-macros/0.2.1")] +#![allow(clippy::needless_doctest_main)] #![warn( missing_debug_implementations, missing_docs, diff --git a/tokio-util/src/lib.rs b/tokio-util/src/lib.rs index 4cb54dfb..48c0fd16 100644 --- a/tokio-util/src/lib.rs +++ b/tokio-util/src/lib.rs @@ -1,4 +1,5 @@ #![doc(html_root_url = "https://docs.rs/tokio-util/0.2.0")] +#![allow(clippy::needless_doctest_main)] #![warn( missing_debug_implementations, missing_docs, diff --git a/tokio/src/lib.rs b/tokio/src/lib.rs index 23f5862f..b11600b4 100644 --- a/tokio/src/lib.rs +++ b/tokio/src/lib.rs @@ -1,5 +1,5 @@ #![doc(html_root_url = "https://docs.rs/tokio/0.2.6")] -#![allow(clippy::cognitive_complexity)] +#![allow(clippy::cognitive_complexity, clippy::needless_doctest_main)] #![warn( missing_debug_implementations, missing_docs, diff --git a/tokio/src/stream/iter.rs b/tokio/src/stream/iter.rs index dc06495e..5909b4cf 100644 --- a/tokio/src/stream/iter.rs +++ b/tokio/src/stream/iter.rs @@ -30,7 +30,8 @@ impl Unpin for Iter {} /// # } /// ``` pub fn iter(i: I) -> Iter - where I: IntoIterator, +where + I: IntoIterator, { Iter { iter: i.into_iter(), @@ -38,7 +39,8 @@ pub fn iter(i: I) -> Iter } impl Stream for Iter - where I: Iterator, +where + I: Iterator, { type Item = I::Item; diff --git a/tokio/src/stream/map.rs b/tokio/src/stream/map.rs index a89769de..cc0c84e0 100644 --- a/tokio/src/stream/map.rs +++ b/tokio/src/stream/map.rs @@ -20,15 +20,14 @@ where St: fmt::Debug, { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("Map") - .field("stream", &self.stream) - .finish() + f.debug_struct("Map").field("stream", &self.stream).finish() } } impl Map - where St: Stream, - F: FnMut(St::Item) -> T, +where + St: Stream, + F: FnMut(St::Item) -> T, { pub(super) fn new(stream: St, f: F) -> Map { Map { stream, f } @@ -36,17 +35,16 @@ impl Map } impl Stream for Map - where St: Stream, - F: FnMut(St::Item) -> T, +where + St: Stream, + F: FnMut(St::Item) -> T, { type Item = T; - fn poll_next( - mut self: Pin<&mut Self>, - cx: &mut Context<'_>, - ) -> Poll> { + fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { self.as_mut() - .project().stream + .project() + .stream .poll_next(cx) .map(|opt| opt.map(|x| (self.as_mut().project().f)(x))) } diff --git a/tokio/src/stream/mod.rs b/tokio/src/stream/mod.rs index 04e6dc06..2d48bc7e 100644 --- a/tokio/src/stream/mod.rs +++ b/tokio/src/stream/mod.rs @@ -1,6 +1,6 @@ //! Stream utilities for Tokio. //! -//! `Stream`s are an asynchoronous version of standard library's Iterator. +//! A `Stream` is an asynchronous sequence of values. It can be thought of as an asynchronous version of the standard library's `Iterator` trait. //! //! This module provides helpers to work with them. diff --git a/tokio/src/stream/next.rs b/tokio/src/stream/next.rs index 3b0a1dd8..5139fbea 100644 --- a/tokio/src/stream/next.rs +++ b/tokio/src/stream/next.rs @@ -22,10 +22,7 @@ impl<'a, St: ?Sized + Stream + Unpin> Next<'a, St> { impl Future for Next<'_, St> { type Output = Option; - fn poll( - mut self: Pin<&mut Self>, - cx: &mut Context<'_>, - ) -> Poll { + fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { Pin::new(&mut self.stream).poll_next(cx) } } diff --git a/tokio/tests/rt_basic.rs b/tokio/tests/rt_basic.rs index 4f0beab9..38a72692 100644 --- a/tokio/tests/rt_basic.rs +++ b/tokio/tests/rt_basic.rs @@ -44,7 +44,7 @@ fn acquire_mutex_in_drop() { rt.spawn(async move { let _ = rx1.await; - let _ = tx2.send(()).unwrap(); + tx2.send(()).unwrap(); unreachable!(); }); diff --git a/tokio/tests/sync_broadcast.rs b/tokio/tests/sync_broadcast.rs index 257595ca..b6f48ca5 100644 --- a/tokio/tests/sync_broadcast.rs +++ b/tokio/tests/sync_broadcast.rs @@ -1,3 +1,4 @@ +#![allow(clippy::cognitive_complexity)] #![warn(rust_2018_idioms)] #![cfg(feature = "sync")] diff --git a/tokio/tests/task_local_set.rs b/tokio/tests/task_local_set.rs index f5014275..e7cce3aa 100644 --- a/tokio/tests/task_local_set.rs +++ b/tokio/tests/task_local_set.rs @@ -22,7 +22,7 @@ fn acquire_mutex_in_drop() { local.spawn_local(async move { let _ = rx1.await; - let _ = tx2.send(()).unwrap(); + tx2.send(()).unwrap(); unreachable!(); }); -- cgit v1.2.3