From d1f60ac4c69792211f9c9f3bcff1559bc0cb837a Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Thu, 19 Sep 2019 15:50:12 +0900 Subject: chore: deny warnings for doc tests (#1539) --- tokio-buf/src/lib.rs | 5 ++++- tokio-codec/src/length_delimited.rs | 4 ---- tokio-codec/src/lib.rs | 5 ++++- tokio-executor/src/executor.rs | 2 +- tokio-executor/src/lib.rs | 5 ++++- tokio-executor/src/threadpool/blocking.rs | 2 +- tokio-executor/src/typed.rs | 2 +- tokio-fs/src/lib.rs | 5 ++++- tokio-io/src/lib.rs | 5 ++++- tokio-macros/src/lib.rs | 5 ++++- tokio-net/src/driver/mod.rs | 2 +- tokio-net/src/lib.rs | 5 ++++- tokio-net/src/tcp/listener.rs | 6 ++++-- tokio-net/src/tcp/stream.rs | 3 +-- tokio-net/src/util/poll_evented.rs | 2 +- tokio-sync/src/lib.rs | 5 ++++- tokio-sync/src/watch.rs | 4 ++-- tokio-test/src/lib.rs | 5 ++++- tokio-test/src/macros.rs | 1 - tokio-timer/src/lib.rs | 5 ++++- tokio-timer/src/timeout.rs | 12 +++++++----- tokio-tls/src/lib.rs | 5 ++++- tokio/src/executor.rs | 2 +- tokio/src/lib.rs | 5 ++++- tokio/src/runtime/current_thread/mod.rs | 8 +++----- tokio/src/runtime/mod.rs | 2 +- tokio/src/runtime/threadpool/builder.rs | 14 +++++++------- tokio/src/runtime/threadpool/mod.rs | 3 --- tokio/src/runtime/threadpool/task_executor.rs | 2 +- tokio/src/timer.rs | 3 +-- 30 files changed, 81 insertions(+), 53 deletions(-) diff --git a/tokio-buf/src/lib.rs b/tokio-buf/src/lib.rs index 2d45de6d..f9adf8a6 100644 --- a/tokio-buf/src/lib.rs +++ b/tokio-buf/src/lib.rs @@ -6,7 +6,10 @@ unreachable_pub )] #![deny(intra_doc_link_resolution_failure)] -#![doc(test(no_crate_inject, attr(deny(rust_2018_idioms))))] +#![doc(test( + no_crate_inject, + attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables)) +))] //! Asynchronous stream of bytes. //! diff --git a/tokio-codec/src/length_delimited.rs b/tokio-codec/src/length_delimited.rs index 830499ac..ff3400de 100644 --- a/tokio-codec/src/length_delimited.rs +++ b/tokio-codec/src/length_delimited.rs @@ -315,7 +315,6 @@ //! ``` //! # use tokio_io::AsyncWrite; //! # use tokio_codec::LengthDelimitedCodec; -//! # use bytes::BytesMut; //! # fn write_frame(io: T) { //! # let _ = //! LengthDelimitedCodec::builder() @@ -842,7 +841,6 @@ impl Builder { /// # Examples /// /// ``` - /// # use tokio_io::AsyncRead; /// use tokio_codec::LengthDelimitedCodec; /// # pub fn main() { /// LengthDelimitedCodec::builder() @@ -892,7 +890,6 @@ impl Builder { /// ``` /// # use tokio_io::AsyncWrite; /// # use tokio_codec::LengthDelimitedCodec; - /// # use bytes::BytesMut; /// # fn write_frame(io: T) { /// LengthDelimitedCodec::builder() /// .length_field_length(2) @@ -914,7 +911,6 @@ impl Builder { /// ``` /// # use tokio_io::{AsyncRead, AsyncWrite}; /// # use tokio_codec::LengthDelimitedCodec; - /// # use bytes::BytesMut; /// # fn write_frame(io: T) { /// # let _ = /// LengthDelimitedCodec::builder() diff --git a/tokio-codec/src/lib.rs b/tokio-codec/src/lib.rs index 9ac923cc..d70f12ba 100644 --- a/tokio-codec/src/lib.rs +++ b/tokio-codec/src/lib.rs @@ -6,7 +6,10 @@ unreachable_pub )] #![deny(intra_doc_link_resolution_failure)] -#![doc(test(no_crate_inject, attr(deny(rust_2018_idioms))))] +#![doc(test( + no_crate_inject, + attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables)) +))] //! Utilities for encoding and decoding frames. //! diff --git a/tokio-executor/src/executor.rs b/tokio-executor/src/executor.rs index 3df6bbc2..964a4099 100644 --- a/tokio-executor/src/executor.rs +++ b/tokio-executor/src/executor.rs @@ -149,7 +149,7 @@ impl dyn Executor { /// println!("running on the executor"); /// })).unwrap(); /// - /// handle.map(|_| println!("the future has completed")); + /// let handle = handle.map(|_| println!("the future has completed")); /// # } /// ``` pub fn spawn_with_handle( diff --git a/tokio-executor/src/lib.rs b/tokio-executor/src/lib.rs index 74193555..df785d57 100644 --- a/tokio-executor/src/lib.rs +++ b/tokio-executor/src/lib.rs @@ -6,7 +6,10 @@ unreachable_pub )] #![deny(intra_doc_link_resolution_failure)] -#![doc(test(no_crate_inject, attr(deny(rust_2018_idioms))))] +#![doc(test( + no_crate_inject, + attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables)) +))] //! Task execution related traits and utilities. //! diff --git a/tokio-executor/src/threadpool/blocking.rs b/tokio-executor/src/threadpool/blocking.rs index 091a8392..ebe20747 100644 --- a/tokio-executor/src/threadpool/blocking.rs +++ b/tokio-executor/src/threadpool/blocking.rs @@ -104,7 +104,7 @@ pub struct BlockingError { /// // from the context of a `Future` implementation. Since we don't /// // have a complicated requirement, we can use `poll_fn` in this /// // case. -/// poll_fn(move |_| { +/// let _ = poll_fn(move |_| { /// blocking(|| { /// let msg = rx.recv().unwrap(); /// println!("message = {}", msg); diff --git a/tokio-executor/src/typed.rs b/tokio-executor/src/typed.rs index 302ba896..ae22cec2 100644 --- a/tokio-executor/src/typed.rs +++ b/tokio-executor/src/typed.rs @@ -63,7 +63,7 @@ use crate::SpawnError; /// if item.is_none() { break; } /// } /// -/// self.tx.take().unwrap().send(()).map_err(|_| ()); +/// let _ = self.tx.take().unwrap().send(()).map_err(|_| ()); /// Poll::Ready(()) /// } /// } diff --git a/tokio-fs/src/lib.rs b/tokio-fs/src/lib.rs index a805cf32..49b7b67d 100644 --- a/tokio-fs/src/lib.rs +++ b/tokio-fs/src/lib.rs @@ -6,7 +6,10 @@ unreachable_pub )] #![deny(intra_doc_link_resolution_failure)] -#![doc(test(no_crate_inject, attr(deny(rust_2018_idioms))))] +#![doc(test( + no_crate_inject, + attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables)) +))] //! Asynchronous file and standard stream adaptation. //! diff --git a/tokio-io/src/lib.rs b/tokio-io/src/lib.rs index 0e9c5f72..b4fd2c2d 100644 --- a/tokio-io/src/lib.rs +++ b/tokio-io/src/lib.rs @@ -6,7 +6,10 @@ unreachable_pub )] #![deny(intra_doc_link_resolution_failure)] -#![doc(test(no_crate_inject, attr(deny(rust_2018_idioms))))] +#![doc(test( + no_crate_inject, + attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables)) +))] //! Core I/O traits and combinators when working with Tokio. //! diff --git a/tokio-macros/src/lib.rs b/tokio-macros/src/lib.rs index 5f6ba20b..d92ea8d9 100644 --- a/tokio-macros/src/lib.rs +++ b/tokio-macros/src/lib.rs @@ -6,7 +6,10 @@ unreachable_pub )] #![deny(intra_doc_link_resolution_failure)] -#![doc(test(no_crate_inject, attr(deny(rust_2018_idioms))))] +#![doc(test( + no_crate_inject, + attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables)) +))] //! Macros for use with Tokio diff --git a/tokio-net/src/driver/mod.rs b/tokio-net/src/driver/mod.rs index 381c9e57..a05a2f30 100644 --- a/tokio-net/src/driver/mod.rs +++ b/tokio-net/src/driver/mod.rs @@ -23,7 +23,7 @@ //! ``` //! use tokio::net::TcpStream; //! -//! # async fn process(t: T) {} +//! # async fn process(_t: T) {} //! # async fn dox() -> Result<(), Box> { //! let stream = TcpStream::connect("93.184.216.34:9243").await?; //! diff --git a/tokio-net/src/lib.rs b/tokio-net/src/lib.rs index cd2c6bc3..2fa13b63 100644 --- a/tokio-net/src/lib.rs +++ b/tokio-net/src/lib.rs @@ -6,7 +6,10 @@ unreachable_pub )] #![deny(intra_doc_link_resolution_failure)] -#![doc(test(no_crate_inject, attr(deny(rust_2018_idioms))))] +#![doc(test( + no_crate_inject, + attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables)) +))] //! Event loop that drives Tokio I/O resources. //! diff --git a/tokio-net/src/tcp/listener.rs b/tokio-net/src/tcp/listener.rs index 81cd71b6..b25f2560 100644 --- a/tokio-net/src/tcp/listener.rs +++ b/tokio-net/src/tcp/listener.rs @@ -25,7 +25,7 @@ use std::task::{Context, Poll}; /// use tokio::net::TcpListener; /// /// use std::io; -/// # async fn process_socket(socket: T) {} +/// # async fn process_socket(_socket: T) {} /// /// #[tokio::main] /// async fn main() -> io::Result<()> { @@ -33,7 +33,7 @@ use std::task::{Context, Poll}; /// /// loop { /// let (socket, _) = listener.accept().await?; -/// process_socket(socket); +/// process_socket(socket).await; /// } /// } /// ``` @@ -70,6 +70,7 @@ impl TcpListener { /// /// // use the listener /// + /// # let _ = listener; /// Ok(()) /// } /// ``` @@ -197,6 +198,7 @@ impl TcpListener { /// /// let std_listener = StdTcpListener::bind("127.0.0.1:0")?; /// let listener = TcpListener::from_std(std_listener, &Handle::default())?; + /// # let _ = listener; /// # Ok::<_, Box>(()) /// ``` pub fn from_std(listener: net::TcpListener, handle: &Handle) -> io::Result { diff --git a/tokio-net/src/tcp/stream.rs b/tokio-net/src/tcp/stream.rs index b5368127..ea841c26 100644 --- a/tokio-net/src/tcp/stream.rs +++ b/tokio-net/src/tcp/stream.rs @@ -270,14 +270,13 @@ impl TcpStream { /// /// ```no_run /// use tokio::net::TcpStream; - /// use tokio::prelude::*; /// use std::error::Error; /// use std::net::Shutdown; /// /// #[tokio::main] /// async fn main() -> Result<(), Box> { /// // Connect to a peer - /// let mut stream = TcpStream::connect("127.0.0.1:8080").await?; + /// let stream = TcpStream::connect("127.0.0.1:8080").await?; /// /// // Shutdown the stream /// stream.shutdown(Shutdown::Write)?; diff --git a/tokio-net/src/util/poll_evented.rs b/tokio-net/src/util/poll_evented.rs index 29dd94fc..2d94a9b8 100644 --- a/tokio-net/src/util/poll_evented.rs +++ b/tokio-net/src/util/poll_evented.rs @@ -76,7 +76,7 @@ use std::task::{Context, Poll}; /// match self.poll_evented.get_ref().accept() { /// Ok((socket, _)) => Poll::Ready(Ok(socket)), /// Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => { -/// self.poll_evented.clear_read_ready(cx, ready); +/// self.poll_evented.clear_read_ready(cx, ready)?; /// Poll::Pending /// } /// Err(e) => Poll::Ready(Err(e)), diff --git a/tokio-sync/src/lib.rs b/tokio-sync/src/lib.rs index f88229cd..28d1ce74 100644 --- a/tokio-sync/src/lib.rs +++ b/tokio-sync/src/lib.rs @@ -6,7 +6,10 @@ unreachable_pub )] #![deny(intra_doc_link_resolution_failure)] -#![doc(test(no_crate_inject, attr(deny(rust_2018_idioms))))] +#![doc(test( + no_crate_inject, + attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables)) +))] //! Asynchronous synchronization primitives. //! diff --git a/tokio-sync/src/watch.rs b/tokio-sync/src/watch.rs index 1841fd0a..7b1e6240 100644 --- a/tokio-sync/src/watch.rs +++ b/tokio-sync/src/watch.rs @@ -21,7 +21,7 @@ //! use tokio::sync::watch; //! //! # async fn dox() -> Result<(), Box> { -//! let (mut tx, mut rx) = watch::channel("hello"); +//! let (tx, mut rx) = watch::channel("hello"); //! //! tokio::spawn(async move { //! while let Some(value) = rx.recv().await { @@ -172,7 +172,7 @@ const CLOSED: usize = 1; /// use tokio::sync::watch; /// /// # async fn dox() -> Result<(), Box> { -/// let (mut tx, mut rx) = watch::channel("hello"); +/// let (tx, mut rx) = watch::channel("hello"); /// /// tokio::spawn(async move { /// while let Some(value) = rx.recv().await { diff --git a/tokio-test/src/lib.rs b/tokio-test/src/lib.rs index 14bc2826..277308c0 100644 --- a/tokio-test/src/lib.rs +++ b/tokio-test/src/lib.rs @@ -6,7 +6,10 @@ unreachable_pub )] #![deny(intra_doc_link_resolution_failure)] -#![doc(test(no_crate_inject, attr(deny(rust_2018_idioms))))] +#![doc(test( + no_crate_inject, + attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables)) +))] //! Tokio and Futures based testing utilites diff --git a/tokio-test/src/macros.rs b/tokio-test/src/macros.rs index d8b3b2ba..b39b4a02 100644 --- a/tokio-test/src/macros.rs +++ b/tokio-test/src/macros.rs @@ -134,7 +134,6 @@ macro_rules! assert_ready_err { /// /// ``` /// use std::future::Future; -/// use std::task::Poll; /// use futures_util::{future, pin_mut}; /// use tokio_test::{assert_pending, task}; /// diff --git a/tokio-timer/src/lib.rs b/tokio-timer/src/lib.rs index 4fa93385..a8cce26e 100644 --- a/tokio-timer/src/lib.rs +++ b/tokio-timer/src/lib.rs @@ -6,7 +6,10 @@ unreachable_pub )] #![deny(intra_doc_link_resolution_failure)] -#![doc(test(no_crate_inject, attr(deny(rust_2018_idioms))))] +#![doc(test( + no_crate_inject, + attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables)) +))] //! Utilities for tracking time. //! diff --git a/tokio-timer/src/timeout.rs b/tokio-timer/src/timeout.rs index 250dc828..0b9d0110 100644 --- a/tokio-timer/src/timeout.rs +++ b/tokio-timer/src/timeout.rs @@ -38,7 +38,7 @@ use std::time::{Duration, Instant}; /// use std::thread; /// use std::time::Duration; /// -/// # async fn dox() { +/// # async fn dox() -> Result<(), Box> { /// let (mut tx, rx) = mpsc::unbounded_channel(); /// /// thread::spawn(move || { @@ -54,7 +54,8 @@ use std::time::{Duration, Instant}; /// }); /// /// // Wrap the future with a `Timeout` set to expire in 10 milliseconds. -/// process.timeout(Duration::from_millis(10)).await; +/// process.timeout(Duration::from_millis(10)).await?; +/// # Ok(()) /// # } /// ``` /// @@ -99,13 +100,14 @@ impl Timeout { /// /// use std::time::Duration; /// - /// # async fn dox() { + /// # async fn dox() -> Result<(), Box> { /// let (tx, rx) = oneshot::channel(); /// # tx.send(()).unwrap(); /// /// // Wrap the future with a `Timeout` set to expire in 10 milliseconds. - /// Timeout::new(rx, Duration::from_millis(10)).await; - /// } + /// Timeout::new(rx, Duration::from_millis(10)).await??; + /// # Ok(()) + /// # } /// ``` pub fn new(value: T, timeout: Duration) -> Timeout { let delay = Delay::new_timeout(now() + timeout, timeout); diff --git a/tokio-tls/src/lib.rs b/tokio-tls/src/lib.rs index 37c7c2ce..df1e4f85 100644 --- a/tokio-tls/src/lib.rs +++ b/tokio-tls/src/lib.rs @@ -6,7 +6,10 @@ unreachable_pub )] #![deny(intra_doc_link_resolution_failure)] -#![doc(test(no_crate_inject, attr(deny(rust_2018_idioms))))] +#![doc(test( + no_crate_inject, + attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables)) +))] //! Async TLS streams //! diff --git a/tokio/src/executor.rs b/tokio/src/executor.rs index 75f0f9d4..710ed2b9 100644 --- a/tokio/src/executor.rs +++ b/tokio/src/executor.rs @@ -71,7 +71,7 @@ pub struct Spawn(()); /// ``` /// use tokio::net::TcpListener; /// -/// # async fn process(t: T) {} +/// # async fn process(_t: T) {} /// # async fn dox() -> Result<(), Box> { /// let mut listener = TcpListener::bind("127.0.0.1:8080").await?; /// diff --git a/tokio/src/lib.rs b/tokio/src/lib.rs index 68f10bc7..b9758f00 100644 --- a/tokio/src/lib.rs +++ b/tokio/src/lib.rs @@ -6,7 +6,10 @@ unreachable_pub )] #![deny(intra_doc_link_resolution_failure)] -#![doc(test(no_crate_inject, attr(deny(rust_2018_idioms))))] +#![doc(test( + no_crate_inject, + attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables)) +))] //! A runtime for writing reliable, asynchronous, and slim applications. //! diff --git a/tokio/src/runtime/current_thread/mod.rs b/tokio/src/runtime/current_thread/mod.rs index c4ed70c6..4b237d35 100644 --- a/tokio/src/runtime/current_thread/mod.rs +++ b/tokio/src/runtime/current_thread/mod.rs @@ -25,14 +25,13 @@ //! //! ``` //! use tokio::runtime::current_thread::Runtime; -//! use tokio::prelude::*; //! use std::thread; //! -//! let mut runtime = Runtime::new().unwrap(); +//! let runtime = Runtime::new().unwrap(); //! let handle = runtime.handle(); //! //! thread::spawn(move || { -//! handle.spawn(async { +//! let _ = handle.spawn(async { //! println!("hello world"); //! }); //! }).join().unwrap(); @@ -45,9 +44,8 @@ //! //! ``` //! use tokio::runtime::current_thread::Runtime; -//! use tokio::prelude::*; //! -//! let mut runtime = Runtime::new().unwrap(); +//! let runtime = Runtime::new().unwrap(); //! //! // Use the runtime... //! // runtime.block_on(f); // where f is a future diff --git a/tokio/src/runtime/mod.rs b/tokio/src/runtime/mod.rs index 4ba6663a..ee33d08c 100644 --- a/tokio/src/runtime/mod.rs +++ b/tokio/src/runtime/mod.rs @@ -86,7 +86,7 @@ //! //! fn main() -> Result<(), Box> { //! // Create the runtime -//! let mut rt = Runtime::new()?; +//! let rt = Runtime::new()?; //! //! // Spawn the root task //! rt.block_on(async { diff --git a/tokio/src/runtime/threadpool/builder.rs b/tokio/src/runtime/threadpool/builder.rs index d045c398..13173095 100644 --- a/tokio/src/runtime/threadpool/builder.rs +++ b/tokio/src/runtime/threadpool/builder.rs @@ -35,7 +35,7 @@ use std::any::Any; /// /// fn main() { /// // build Runtime -/// let mut runtime = Builder::new() +/// let runtime = Builder::new() /// .blocking_threads(4) /// .clock(Clock::system()) /// .core_threads(4) @@ -99,7 +99,7 @@ impl Builder { /// # use tokio::runtime; /// /// # pub fn main() { - /// let mut rt = runtime::Builder::new() + /// let rt = runtime::Builder::new() /// .panic_handler(|err| std::panic::resume_unwind(err)) /// .build() /// .unwrap(); @@ -127,7 +127,7 @@ impl Builder { /// # use tokio::runtime; /// /// # pub fn main() { - /// let mut rt = runtime::Builder::new() + /// let rt = runtime::Builder::new() /// .core_threads(4) /// .build() /// .unwrap(); @@ -157,7 +157,7 @@ impl Builder { /// # use tokio::runtime; /// /// # pub fn main() { - /// let mut rt = runtime::Builder::new() + /// let rt = runtime::Builder::new() /// .blocking_threads(200) /// .build(); /// # } @@ -186,7 +186,7 @@ impl Builder { /// use std::time::Duration; /// /// # pub fn main() { - /// let mut rt = runtime::Builder::new() + /// let rt = runtime::Builder::new() /// .keep_alive(Some(Duration::from_secs(30))) /// .build(); /// # } @@ -210,7 +210,7 @@ impl Builder { /// # use tokio::runtime; /// /// # pub fn main() { - /// let mut rt = runtime::Builder::new() + /// let rt = runtime::Builder::new() /// .name_prefix("my-pool-") /// .build(); /// # } @@ -234,7 +234,7 @@ impl Builder { /// # use tokio::runtime; /// /// # pub fn main() { - /// let mut rt = runtime::Builder::new() + /// let rt = runtime::Builder::new() /// .stack_size(32 * 1024) /// .build(); /// # } diff --git a/tokio/src/runtime/threadpool/mod.rs b/tokio/src/runtime/threadpool/mod.rs index c2564cb8..47009cc4 100644 --- a/tokio/src/runtime/threadpool/mod.rs +++ b/tokio/src/runtime/threadpool/mod.rs @@ -75,7 +75,6 @@ impl Runtime { /// /// ``` /// use tokio::runtime::Runtime; - /// use tokio::prelude::*; /// /// let rt = Runtime::new() /// .unwrap(); @@ -198,7 +197,6 @@ impl Runtime { /// /// ``` /// use tokio::runtime::Runtime; - /// use tokio::prelude::*; /// /// let rt = Runtime::new() /// .unwrap(); @@ -239,7 +237,6 @@ impl Runtime { /// /// ``` /// use tokio::runtime::Runtime; - /// use tokio::prelude::*; /// /// let rt = Runtime::new() /// .unwrap(); diff --git a/tokio/src/runtime/threadpool/task_executor.rs b/tokio/src/runtime/threadpool/task_executor.rs index ddf764cc..3107ac11 100644 --- a/tokio/src/runtime/threadpool/task_executor.rs +++ b/tokio/src/runtime/threadpool/task_executor.rs @@ -33,7 +33,7 @@ impl TaskExecutor { /// /// # fn dox() { /// // Create the runtime - /// let mut rt = Runtime::new().unwrap(); + /// let rt = Runtime::new().unwrap(); /// let executor = rt.executor(); /// /// // Spawn a future onto the runtime diff --git a/tokio/src/timer.rs b/tokio/src/timer.rs index 024903d5..eaedee27 100644 --- a/tokio/src/timer.rs +++ b/tokio/src/timer.rs @@ -30,10 +30,9 @@ //! Wait 100ms and print "Hello World!" //! //! ``` -//! use tokio::prelude::*; //! use tokio::timer::delay; //! -//! use std::time::{Duration, Instant}; +//! use std::time::Duration; //! //! //! #[tokio::main] -- cgit v1.2.3