Skip to content

Deny warnings for doc tests #1672

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 1 commit into from
Jun 14, 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
2 changes: 2 additions & 0 deletions futures-channel/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#![warn(missing_docs, missing_debug_implementations, rust_2018_idioms, unreachable_pub)]
#![warn(clippy::all)]

#![doc(test(attr(deny(warnings), allow(dead_code, unused_assignments, unused_variables))))]

#![doc(html_root_url = "https://rust-lang-nursery.github.io/futures-api-docs/0.3.0-alpha.16/futures_channel")]

#[cfg(feature = "std")]
Expand Down
2 changes: 2 additions & 0 deletions futures-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#![warn(missing_docs, missing_debug_implementations, rust_2018_idioms, unreachable_pub)]
#![warn(clippy::all)]

#![doc(test(attr(deny(warnings), allow(dead_code, unused_assignments, unused_variables))))]

#![doc(html_root_url = "https://rust-lang-nursery.github.io/futures-api-docs/0.3.0-alpha.16/futures_core")]

#[cfg(all(feature = "cfg-target-has-atomic", not(feature = "nightly")))]
Expand Down
2 changes: 1 addition & 1 deletion futures-core/src/task/__internal/atomic_waker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ impl AtomicWaker {
/// impl Future for Flag {
/// type Output = ();
///
/// fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> {
/// fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> {
/// // Register **before** checking `set` to avoid a race condition
/// // that would result in lost notifications.
/// self.waker.register(cx.waker());
Expand Down
2 changes: 2 additions & 0 deletions futures-executor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#![warn(missing_docs, missing_debug_implementations, rust_2018_idioms, unreachable_pub)]
#![warn(clippy::all)]

#![doc(test(attr(deny(warnings), allow(dead_code, unused_assignments, unused_variables))))]

#![doc(html_root_url = "https://rust-lang-nursery.github.io/futures-api-docs/0.3.0-alpha.16/futures_executor")]

#[cfg(feature = "std")]
Expand Down
14 changes: 7 additions & 7 deletions futures-executor/src/local_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,16 +175,16 @@ impl LocalPool {
/// let mut pool = LocalPool::new();
/// let mut spawner = pool.spawner();
///
/// spawner.spawn_local(ready(()));
/// spawner.spawn_local(ready(()));
/// spawner.spawn_local(empty());
/// spawner.spawn_local(ready(())).unwrap();
/// spawner.spawn_local(ready(())).unwrap();
/// spawner.spawn_local(empty()).unwrap();
///
/// // Run the two ready tasks and return true for them.
/// pool.try_run_one(); // returns true after completing one of the ready futures
/// pool.try_run_one(); // returns true after completing the other ready future
///
/// // the remaining task can not be completed
/// pool.try_run_one(); // returns false
/// assert!(!pool.try_run_one()); // returns false
/// ```
///
/// This function will not block the calling thread and will return the moment
Expand Down Expand Up @@ -215,9 +215,9 @@ impl LocalPool {
/// let mut pool = LocalPool::new();
/// let mut spawner = pool.spawner();
///
/// spawner.spawn_local(ready(()));
/// spawner.spawn_local(ready(()));
/// spawner.spawn_local(empty());
/// spawner.spawn_local(ready(())).unwrap();
/// spawner.spawn_local(ready(())).unwrap();
/// spawner.spawn_local(empty()).unwrap();
///
/// // Runs the two ready task and returns.
/// // The empty task remains in the pool.
Expand Down
2 changes: 2 additions & 0 deletions futures-io/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#![warn(missing_docs, missing_debug_implementations, rust_2018_idioms, unreachable_pub)]
#![warn(clippy::all)]

#![doc(test(attr(deny(warnings), allow(dead_code, unused_assignments, unused_variables))))]

#![doc(html_root_url = "https://rust-lang-nursery.github.io/futures-api-docs/0.3.0-alpha.16/futures_io")]

#[cfg(feature = "std")]
Expand Down
2 changes: 2 additions & 0 deletions futures-sink/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#![warn(missing_docs, missing_debug_implementations, rust_2018_idioms, unreachable_pub)]
#![warn(clippy::all)]

#![doc(test(attr(deny(warnings), allow(dead_code, unused_assignments, unused_variables))))]

#![doc(html_root_url = "https://rust-lang-nursery.github.io/futures-api-docs/0.3.0-alpha.16/futures_sink")]

#[cfg(feature = "alloc")]
Expand Down
6 changes: 3 additions & 3 deletions futures-test/src/assert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub fn assert_is_unpin_stream<S: Stream + Unpin>(_: &mut S) {}
/// };
/// use pin_utils::pin_mut;
///
/// let mut stream = stream::once((async { 5 }).pending_once());
/// let stream = stream::once((async { 5 }).pending_once());
/// pin_mut!(stream);
///
/// assert_stream_pending!(stream);
Expand Down Expand Up @@ -54,7 +54,7 @@ macro_rules! assert_stream_pending {
/// };
/// use pin_utils::pin_mut;
///
/// let mut stream = stream::once((async { 5 }).pending_once());
/// let stream = stream::once((async { 5 }).pending_once());
/// pin_mut!(stream);
///
/// assert_stream_pending!(stream);
Expand Down Expand Up @@ -97,7 +97,7 @@ macro_rules! assert_stream_next {
/// };
/// use pin_utils::pin_mut;
///
/// let mut stream = stream::once((async { 5 }).pending_once());
/// let stream = stream::once((async { 5 }).pending_once());
/// pin_mut!(stream);
///
/// assert_stream_pending!(stream);
Expand Down
2 changes: 2 additions & 0 deletions futures-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#![warn(missing_docs, missing_debug_implementations, rust_2018_idioms, unreachable_pub)]
#![warn(clippy::all)]

#![doc(test(attr(deny(warnings), allow(dead_code, unused_assignments, unused_variables))))]

#![doc(html_root_url = "https://rust-lang-nursery.github.io/futures-api-docs/0.3.0-alpha.16/futures_test")]

#[cfg(not(feature = "std"))]
Expand Down
2 changes: 1 addition & 1 deletion futures-test/src/task/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub fn panic_context() -> Context<'static> {
/// use futures_test::task::noop_context;
/// use pin_utils::pin_mut;
///
/// let mut future = async { 5 };
/// let future = async { 5 };
/// pin_mut!(future);
///
/// assert_eq!(future.poll(&mut noop_context()), Poll::Ready(5));
Expand Down
4 changes: 2 additions & 2 deletions futures-test/src/task/noop_spawner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use futures_core::task::{Spawn, SpawnError};
/// use futures_test::task::NoopSpawner;
///
/// let mut spawner = NoopSpawner::new();
/// spawner.spawn(async { });
/// spawner.spawn(async { }).unwrap();
/// ```
#[derive(Debug)]
pub struct NoopSpawner {
Expand Down Expand Up @@ -51,7 +51,7 @@ impl Default for NoopSpawner {
/// use futures_test::task::noop_spawner_mut;
///
/// let spawner = noop_spawner_mut();
/// spawner.spawn(async { });
/// spawner.spawn(async { }).unwrap();
/// ```
pub fn noop_spawner_mut() -> &'static mut NoopSpawner {
Box::leak(Box::new(NoopSpawner::new()))
Expand Down
6 changes: 4 additions & 2 deletions futures-test/src/task/panic_spawner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ use futures_core::task::{Spawn, SpawnError};
/// use futures_test::task::PanicSpawner;
///
/// let mut spawn = PanicSpawner::new();
/// spawn.spawn(async { }); // Will panic
/// spawn.spawn(async { })?; // Will panic
/// # Ok::<(), Box<dyn std::error::Error>>(())
/// ```
#[derive(Debug)]
pub struct PanicSpawner {
Expand Down Expand Up @@ -51,7 +52,8 @@ impl Default for PanicSpawner {
/// use futures_test::task::panic_spawner_mut;
///
/// let spawner = panic_spawner_mut();
/// spawner.spawn(async { }); // Will panic
/// spawner.spawn(async { })?; // Will panic
/// # Ok::<(), Box<dyn std::error::Error>>(())
/// ```
pub fn panic_spawner_mut() -> &'static mut PanicSpawner {
Box::leak(Box::new(PanicSpawner::new()))
Expand Down
1 change: 0 additions & 1 deletion futures-test/src/task/panic_waker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ pub fn panic_waker() -> Waker {
///
/// ```should_panic
/// #![feature(async_await)]
/// use futures::task;
/// use futures_test::task::panic_waker_ref;
///
/// let waker = panic_waker_ref();
Expand Down
2 changes: 1 addition & 1 deletion futures-test/src/task/record_spawner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use futures_core::task::{Spawn, SpawnError};
/// use futures_test::task::RecordSpawner;
///
/// let mut recorder = RecordSpawner::new();
/// recorder.spawn(async { });
/// recorder.spawn(async { }).unwrap();
/// assert_eq!(recorder.spawned().len(), 1);
/// ```
#[derive(Debug)]
Expand Down
6 changes: 3 additions & 3 deletions futures-util/src/async_await/select_mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ macro_rules! document_select_macro {
/// ```
/// #![feature(async_await)]
/// # futures::executor::block_on(async {
/// use futures::future::{self, FutureExt};
/// use futures::future;
/// use futures::select;
/// let mut a = future::ready(4);
/// let mut b = future::empty::<()>();
Expand All @@ -45,7 +45,7 @@ macro_rules! document_select_macro {
/// ```
/// #![feature(async_await)]
/// # futures::executor::block_on(async {
/// use futures::future::{self, FutureExt};
/// use futures::future;
/// use futures::stream::{self, StreamExt};
/// use futures::select;
/// let mut st = stream::iter(vec![2]).fuse();
Expand All @@ -67,7 +67,7 @@ macro_rules! document_select_macro {
/// ```
/// #![feature(async_await)]
/// # futures::executor::block_on(async {
/// use futures::future::{self, FutureExt};
/// use futures::future;
/// use futures::select;
/// let mut a_fut = future::ready(4);
/// let mut b_fut = future::ready(6);
Expand Down
1 change: 0 additions & 1 deletion futures-util/src/compat/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ pub trait Executor01CompatExt: Executor01<Executor01Future> +
///
/// ```
/// #![feature(async_await)]
/// use futures::Future;
/// use futures::task::SpawnExt;
/// use futures::future::{FutureExt, TryFutureExt};
/// use futures_util::compat::Executor01CompatExt;
Expand Down
4 changes: 1 addition & 3 deletions futures-util/src/future/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,7 @@ pub trait FutureExt: Future {
///
/// # Examples
///
// TODO: minimize and open rust-lang/rust ticket, currently errors:
// 'assertion failed: !value.has_escaping_regions()'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, this seems to have already been fixed.

/// ```ignore
/// ```
/// #![feature(async_await)]
/// # futures::executor::block_on(async {
/// use futures::future::{self, FutureExt, Ready};
Expand Down
22 changes: 11 additions & 11 deletions futures-util/src/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ pub trait AsyncReadExt: AsyncRead {
///
/// assert_eq!(bytes, 4);
/// assert_eq!(writer.into_inner(), [1, 2, 3, 4, 0]);
/// # Ok::<(), Box<std::error::Error>>(()) }).unwrap();
/// # Ok::<(), Box<dyn std::error::Error>>(()) }).unwrap();
/// ```
fn copy_into<'a, W>(
&'a mut self,
Expand Down Expand Up @@ -137,7 +137,7 @@ pub trait AsyncReadExt: AsyncRead {
/// // `output.len()` bytes in a single read.
/// assert_eq!(bytes, 4);
/// assert_eq!(output, [1, 2, 3, 4, 0]);
/// # Ok::<(), Box<std::error::Error>>(()) }).unwrap();
/// # Ok::<(), Box<dyn std::error::Error>>(()) }).unwrap();
/// ```
fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Read<'a, Self>
where Self: Unpin,
Expand Down Expand Up @@ -178,7 +178,7 @@ pub trait AsyncReadExt: AsyncRead {
/// reader.read_exact(&mut output).await?;
///
/// assert_eq!(output, [1, 2, 3, 4]);
/// # Ok::<(), Box<std::error::Error>>(()) }).unwrap();
/// # Ok::<(), Box<dyn std::error::Error>>(()) }).unwrap();
/// ```
///
/// ## EOF is hit before `buf` is filled
Expand Down Expand Up @@ -222,7 +222,7 @@ pub trait AsyncReadExt: AsyncRead {
/// reader.read_to_end(&mut output).await?;
///
/// assert_eq!(output, vec![1, 2, 3, 4]);
/// # Ok::<(), Box<std::error::Error>>(()) }).unwrap();
/// # Ok::<(), Box<dyn std::error::Error>>(()) }).unwrap();
/// ```
fn read_to_end<'a>(
&'a mut self,
Expand Down Expand Up @@ -262,7 +262,7 @@ pub trait AsyncReadExt: AsyncRead {
///
/// assert_eq!(buffer.into_inner(), [1, 2, 3, 4, 5, 6, 7, 8]);
/// assert_eq!(writer.into_inner(), [5, 6, 7, 8, 0]);
/// # Ok::<(), Box<std::error::Error>>(()) }).unwrap();
/// # Ok::<(), Box<dyn std::error::Error>>(()) }).unwrap();
/// ```
fn split(self) -> (ReadHalf<Self>, WriteHalf<Self>)
where Self: AsyncWrite + Sized,
Expand Down Expand Up @@ -301,15 +301,15 @@ pub trait AsyncWriteExt: AsyncWrite {
/// let mut output = [0u8; 5];
///
/// {
/// let mut writer = Cursor::new(&mut output[..]);
/// let writer = Cursor::new(&mut output[..]);
/// let mut buffered = AllowStdIo::new(BufWriter::new(writer));
/// buffered.write_all(&[1, 2]).await?;
/// buffered.write_all(&[3, 4]).await?;
/// buffered.flush().await?;
/// }
///
/// assert_eq!(output, [1, 2, 3, 4, 0]);
/// # Ok::<(), Box<std::error::Error>>(()) }).unwrap();
/// # Ok::<(), Box<dyn std::error::Error>>(()) }).unwrap();
/// ```
fn flush(&mut self) -> Flush<'_, Self>
where Self: Unpin,
Expand Down Expand Up @@ -365,7 +365,7 @@ pub trait AsyncWriteExt: AsyncWrite {
/// writer.write_all(&[1, 2, 3, 4]).await?;
///
/// assert_eq!(writer.into_inner(), [1, 2, 3, 4, 0]);
/// # Ok::<(), Box<std::error::Error>>(()) }).unwrap();
/// # Ok::<(), Box<dyn std::error::Error>>(()) }).unwrap();
/// ```
fn write_all<'a>(&'a mut self, buf: &'a [u8]) -> WriteAll<'a, Self>
where Self: Unpin,
Expand Down Expand Up @@ -445,7 +445,7 @@ pub trait AsyncBufReadExt: AsyncBufRead {
/// let num_bytes = cursor.read_until(b'-', &mut buf).await?;
/// assert_eq!(num_bytes, 0);
/// assert_eq!(buf, b"");
/// # Ok::<(), Box<std::error::Error>>(()) }).unwrap();
/// # Ok::<(), Box<dyn std::error::Error>>(()) }).unwrap();
/// ```
fn read_until<'a>(
&'a mut self,
Expand Down Expand Up @@ -508,7 +508,7 @@ pub trait AsyncBufReadExt: AsyncBufRead {
/// let num_bytes = cursor.read_line(&mut buf).await?;
/// assert_eq!(num_bytes, 0);
/// assert_eq!(buf, "");
/// # Ok::<(), Box<std::error::Error>>(()) }).unwrap();
/// # Ok::<(), Box<dyn std::error::Error>>(()) }).unwrap();
/// ```
fn read_line<'a>(&'a mut self, buf: &'a mut String) -> ReadLine<'a, Self>
where Self: Unpin,
Expand Down Expand Up @@ -548,7 +548,7 @@ pub trait AsyncBufReadExt: AsyncBufRead {
/// assert_eq!(lines_stream.next().await, Some(String::from("ipsum")));
/// assert_eq!(lines_stream.next().await, Some(String::from("dolor")));
/// assert_eq!(lines_stream.next().await, None);
/// # Ok::<(), Box<std::error::Error>>(()) }).unwrap();
/// # Ok::<(), Box<dyn std::error::Error>>(()) }).unwrap();
/// ```
fn lines(self) -> Lines<Self>
where Self: Sized,
Expand Down
2 changes: 2 additions & 0 deletions futures-util/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#![warn(missing_docs, missing_debug_implementations, rust_2018_idioms, unreachable_pub)]
#![warn(clippy::all)]

#![doc(test(attr(deny(warnings), allow(dead_code, unused_assignments, unused_variables))))]

#![doc(html_root_url = "https://rust-lang-nursery.github.io/futures-api-docs/0.3.0-alpha.16/futures_util")]

#[cfg(all(feature = "cfg-target-has-atomic", not(feature = "nightly")))]
Expand Down
2 changes: 1 addition & 1 deletion futures-util/src/stream/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ impl<I> Unpin for Iter<I> {}
/// # futures::executor::block_on(async {
/// use futures::stream::{self, StreamExt};
///
/// let mut stream = stream::iter(vec![17, 19]);
/// let stream = stream::iter(vec![17, 19]);
/// assert_eq!(vec![17, 19], stream.collect::<Vec<i32>>().await);
/// # });
/// ```
Expand Down
6 changes: 3 additions & 3 deletions futures-util/src/stream/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -944,14 +944,14 @@ pub trait StreamExt: Stream {
/// let stream_of_futures = stream::iter(vec![recv_one, recv_two]);
/// let mut buffered = stream_of_futures.buffer_unordered(10);
///
/// send_two.send(2i32);
/// send_two.send(2i32)?;
/// assert_eq!(buffered.next().await, Some(Ok(2i32)));
///
/// send_one.send(1i32);
/// send_one.send(1i32)?;
/// assert_eq!(buffered.next().await, Some(Ok(1i32)));
///
/// assert_eq!(buffered.next().await, None);
/// # })
/// # Ok::<(), i32>(()) }).unwrap();
/// ```
#[cfg_attr(
feature = "cfg-target-has-atomic",
Expand Down
2 changes: 1 addition & 1 deletion futures-util/src/stream/once.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use pin_utils::unsafe_pinned;
/// use futures::future;
/// use futures::stream::{self, StreamExt};
///
/// let mut stream = stream::once(future::ready(17));
/// let stream = stream::once(future::ready(17));
/// let collected = stream.collect::<Vec<i32>>().await;
/// assert_eq!(collected, vec![17]);
/// # });
Expand Down
2 changes: 1 addition & 1 deletion futures-util/src/stream/repeat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub struct Repeat<T> {
/// # futures::executor::block_on(async {
/// use futures::stream::{self, StreamExt};
///
/// let mut stream = stream::repeat(9);
/// let stream = stream::repeat(9);
/// assert_eq!(vec![9, 9, 9], stream.take(3).collect::<Vec<i32>>().await);
/// # });
/// ```
Expand Down
2 changes: 1 addition & 1 deletion futures-util/src/stream/unfold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use pin_utils::{unsafe_pinned, unsafe_unpinned};
/// use futures::future;
/// use futures::stream::{self, StreamExt};
///
/// let mut stream = stream::unfold(0, |state| {
/// let stream = stream::unfold(0, |state| {
/// if state <= 2 {
/// let next_state = state + 1;
/// let yielded = state * 2;
Expand Down
Loading