chore: deny warnings for doc tests (#1539)

This commit is contained in:
Taiki Endo 2019-09-19 15:50:12 +09:00 committed by GitHub
parent e2161502ad
commit d1f60ac4c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 81 additions and 53 deletions

View File

@ -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.
//!

View File

@ -315,7 +315,6 @@
//! ```
//! # use tokio_io::AsyncWrite;
//! # use tokio_codec::LengthDelimitedCodec;
//! # use bytes::BytesMut;
//! # fn write_frame<T: AsyncWrite>(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<T: AsyncWrite>(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<T: AsyncRead + AsyncWrite>(io: T) {
/// # let _ =
/// LengthDelimitedCodec::builder()

View File

@ -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.
//!

View File

@ -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<Fut>(

View File

@ -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.
//!

View File

@ -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);

View File

@ -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(())
/// }
/// }

View File

@ -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.
//!

View File

@ -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.
//!

View File

@ -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

View File

@ -23,7 +23,7 @@
//! ```
//! use tokio::net::TcpStream;
//!
//! # async fn process<T>(t: T) {}
//! # async fn process<T>(_t: T) {}
//! # async fn dox() -> Result<(), Box<dyn std::error::Error>> {
//! let stream = TcpStream::connect("93.184.216.34:9243").await?;
//!

View File

@ -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.
//!

View File

@ -25,7 +25,7 @@ use std::task::{Context, Poll};
/// use tokio::net::TcpListener;
///
/// use std::io;
/// # async fn process_socket<T>(socket: T) {}
/// # async fn process_socket<T>(_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<dyn std::error::Error>>(())
/// ```
pub fn from_std(listener: net::TcpListener, handle: &Handle) -> io::Result<TcpListener> {

View File

@ -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<dyn Error>> {
/// // 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)?;

View File

@ -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)),

View File

@ -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.
//!

View File

@ -21,7 +21,7 @@
//! use tokio::sync::watch;
//!
//! # async fn dox() -> Result<(), Box<dyn std::error::Error>> {
//! 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<dyn std::error::Error>> {
/// 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 {

View File

@ -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

View File

@ -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};
///

View File

@ -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.
//!

View File

@ -38,7 +38,7 @@ use std::time::{Duration, Instant};
/// use std::thread;
/// use std::time::Duration;
///
/// # async fn dox() {
/// # async fn dox() -> Result<(), Box<dyn std::error::Error>> {
/// 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<T> Timeout<T> {
///
/// use std::time::Duration;
///
/// # async fn dox() {
/// # async fn dox() -> Result<(), Box<dyn std::error::Error>> {
/// 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<T> {
let delay = Delay::new_timeout(now() + timeout, timeout);

View File

@ -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
//!

View File

@ -71,7 +71,7 @@ pub struct Spawn(());
/// ```
/// use tokio::net::TcpListener;
///
/// # async fn process<T>(t: T) {}
/// # async fn process<T>(_t: T) {}
/// # async fn dox() -> Result<(), Box<dyn std::error::Error>> {
/// let mut listener = TcpListener::bind("127.0.0.1:8080").await?;
///

View File

@ -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.
//!

View File

@ -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

View File

@ -86,7 +86,7 @@
//!
//! fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Create the runtime
//! let mut rt = Runtime::new()?;
//! let rt = Runtime::new()?;
//!
//! // Spawn the root task
//! rt.block_on(async {

View File

@ -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();
/// # }

View File

@ -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();

View File

@ -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

View File

@ -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]