Skip to content

chore: deny warnings for doc tests #1539

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion tokio-buf/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
//!
Expand Down
4 changes: 0 additions & 4 deletions tokio-codec/src/length_delimited.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -842,7 +841,6 @@ impl Builder {
/// # Examples
///
/// ```
/// # use tokio_io::AsyncRead;
/// use tokio_codec::LengthDelimitedCodec;
/// # pub fn main() {
/// LengthDelimitedCodec::builder()
Expand Down Expand Up @@ -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)
Expand All @@ -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()
Expand Down
5 changes: 4 additions & 1 deletion tokio-codec/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
//!
Expand Down
2 changes: 1 addition & 1 deletion tokio-executor/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>(
Expand Down
5 changes: 4 additions & 1 deletion tokio-executor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
//!
Expand Down
2 changes: 1 addition & 1 deletion tokio-executor/src/threadpool/blocking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tokio-executor/src/typed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
/// }
/// }
Expand Down
5 changes: 4 additions & 1 deletion tokio-fs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
//!
Expand Down
5 changes: 4 additions & 1 deletion tokio-io/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
//!
Expand Down
5 changes: 4 additions & 1 deletion tokio-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion tokio-net/src/driver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?;
//!
Expand Down
5 changes: 4 additions & 1 deletion tokio-net/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
//!
Expand Down
6 changes: 4 additions & 2 deletions tokio-net/src/tcp/listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ 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<()> {
/// let mut listener = TcpListener::bind("127.0.0.1:8080").await?;
///
/// loop {
/// let (socket, _) = listener.accept().await?;
/// process_socket(socket);
/// process_socket(socket).await;
/// }
/// }
/// ```
Expand Down Expand Up @@ -70,6 +70,7 @@ impl TcpListener {
///
/// // use the listener
///
/// # let _ = listener;
/// Ok(())
/// }
/// ```
Expand Down Expand Up @@ -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> {
Expand Down
3 changes: 1 addition & 2 deletions tokio-net/src/tcp/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand Down
2 changes: 1 addition & 1 deletion tokio-net/src/util/poll_evented.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down
5 changes: 4 additions & 1 deletion tokio-sync/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
//!
Expand Down
4 changes: 2 additions & 2 deletions tokio-sync/src/watch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
5 changes: 4 additions & 1 deletion tokio-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion tokio-test/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
///
Expand Down
5 changes: 4 additions & 1 deletion tokio-timer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
//!
Expand Down
12 changes: 7 additions & 5 deletions tokio-timer/src/timeout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 || {
Expand All @@ -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(())
/// # }
/// ```
///
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion tokio-tls/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
//!
Expand Down
2 changes: 1 addition & 1 deletion tokio/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?;
///
Expand Down
5 changes: 4 additions & 1 deletion tokio/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
//!
Expand Down
8 changes: 3 additions & 5 deletions tokio/src/runtime/current_thread/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tokio/src/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading