Skip to content

Commit 7babf7d

Browse files
committed
Deny warnings for doc tests
1 parent b232653 commit 7babf7d

File tree

26 files changed

+72
-54
lines changed

26 files changed

+72
-54
lines changed

futures-channel/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#![warn(missing_docs, missing_debug_implementations, rust_2018_idioms, unreachable_pub)]
1212
#![warn(clippy::all)]
1313

14+
#![doc(test(attr(deny(warnings), allow(dead_code, unused_assignments, unused_variables))))]
15+
1416
#![doc(html_root_url = "https://rust-lang-nursery.github.io/futures-api-docs/0.3.0-alpha.16/futures_channel")]
1517

1618
#[cfg(feature = "std")]

futures-core/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#![warn(missing_docs, missing_debug_implementations, rust_2018_idioms, unreachable_pub)]
88
#![warn(clippy::all)]
99

10+
#![doc(test(attr(deny(warnings), allow(dead_code, unused_assignments, unused_variables))))]
11+
1012
#![doc(html_root_url = "https://rust-lang-nursery.github.io/futures-api-docs/0.3.0-alpha.16/futures_core")]
1113

1214
#[cfg(all(feature = "cfg-target-has-atomic", not(feature = "nightly")))]

futures-core/src/task/__internal/atomic_waker.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ impl AtomicWaker {
183183
/// impl Future for Flag {
184184
/// type Output = ();
185185
///
186-
/// fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> {
186+
/// fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> {
187187
/// // Register **before** checking `set` to avoid a race condition
188188
/// // that would result in lost notifications.
189189
/// self.waker.register(cx.waker());

futures-executor/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#![warn(missing_docs, missing_debug_implementations, rust_2018_idioms, unreachable_pub)]
99
#![warn(clippy::all)]
1010

11+
#![doc(test(attr(deny(warnings), allow(dead_code, unused_assignments, unused_variables))))]
12+
1113
#![doc(html_root_url = "https://rust-lang-nursery.github.io/futures-api-docs/0.3.0-alpha.16/futures_executor")]
1214

1315
#[cfg(feature = "std")]

futures-executor/src/local_pool.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -175,16 +175,17 @@ impl LocalPool {
175175
/// let mut pool = LocalPool::new();
176176
/// let mut spawner = pool.spawner();
177177
///
178-
/// spawner.spawn_local(ready(()));
179-
/// spawner.spawn_local(ready(()));
180-
/// spawner.spawn_local(empty());
178+
/// spawner.spawn_local(ready(()))?;
179+
/// spawner.spawn_local(ready(()))?;
180+
/// spawner.spawn_local(empty())?;
181181
///
182182
/// // Run the two ready tasks and return true for them.
183183
/// pool.try_run_one(); // returns true after completing one of the ready futures
184184
/// pool.try_run_one(); // returns true after completing the other ready future
185185
///
186186
/// // the remaining task can not be completed
187187
/// pool.try_run_one(); // returns false
188+
/// # Ok::<(), Box<dyn std::error::Error>>(())
188189
/// ```
189190
///
190191
/// This function will not block the calling thread and will return the moment
@@ -215,13 +216,14 @@ impl LocalPool {
215216
/// let mut pool = LocalPool::new();
216217
/// let mut spawner = pool.spawner();
217218
///
218-
/// spawner.spawn_local(ready(()));
219-
/// spawner.spawn_local(ready(()));
220-
/// spawner.spawn_local(empty());
219+
/// spawner.spawn_local(ready(()))?;
220+
/// spawner.spawn_local(ready(()))?;
221+
/// spawner.spawn_local(empty())?;
221222
///
222223
/// // Runs the two ready task and returns.
223224
/// // The empty task remains in the pool.
224225
/// pool.run_until_stalled();
226+
/// # Ok::<(), Box<dyn std::error::Error>>(())
225227
/// ```
226228
///
227229
/// This function will not block the calling thread and will return the moment

futures-io/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#![warn(missing_docs, missing_debug_implementations, rust_2018_idioms, unreachable_pub)]
1414
#![warn(clippy::all)]
1515

16+
#![doc(test(attr(deny(warnings), allow(dead_code, unused_assignments, unused_variables))))]
17+
1618
#![doc(html_root_url = "https://rust-lang-nursery.github.io/futures-api-docs/0.3.0-alpha.16/futures_io")]
1719

1820
#[cfg(feature = "std")]

futures-sink/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#![warn(missing_docs, missing_debug_implementations, rust_2018_idioms, unreachable_pub)]
88
#![warn(clippy::all)]
99

10+
#![doc(test(attr(deny(warnings), allow(dead_code, unused_assignments, unused_variables))))]
11+
1012
#![doc(html_root_url = "https://rust-lang-nursery.github.io/futures-api-docs/0.3.0-alpha.16/futures_sink")]
1113

1214
#[cfg(feature = "alloc")]

futures-test/src/assert.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub fn assert_is_unpin_stream<S: Stream + Unpin>(_: &mut S) {}
1717
/// };
1818
/// use pin_utils::pin_mut;
1919
///
20-
/// let mut stream = stream::once((async { 5 }).pending_once());
20+
/// let stream = stream::once((async { 5 }).pending_once());
2121
/// pin_mut!(stream);
2222
///
2323
/// assert_stream_pending!(stream);
@@ -54,7 +54,7 @@ macro_rules! assert_stream_pending {
5454
/// };
5555
/// use pin_utils::pin_mut;
5656
///
57-
/// let mut stream = stream::once((async { 5 }).pending_once());
57+
/// let stream = stream::once((async { 5 }).pending_once());
5858
/// pin_mut!(stream);
5959
///
6060
/// assert_stream_pending!(stream);
@@ -97,7 +97,7 @@ macro_rules! assert_stream_next {
9797
/// };
9898
/// use pin_utils::pin_mut;
9999
///
100-
/// let mut stream = stream::once((async { 5 }).pending_once());
100+
/// let stream = stream::once((async { 5 }).pending_once());
101101
/// pin_mut!(stream);
102102
///
103103
/// assert_stream_pending!(stream);

futures-test/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#![warn(missing_docs, missing_debug_implementations, rust_2018_idioms, unreachable_pub)]
44
#![warn(clippy::all)]
55

6+
#![doc(test(attr(deny(warnings), allow(dead_code, unused_assignments, unused_variables))))]
7+
68
#![doc(html_root_url = "https://rust-lang-nursery.github.io/futures-api-docs/0.3.0-alpha.16/futures_test")]
79

810
#[cfg(not(feature = "std"))]

futures-test/src/task/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub fn panic_context() -> Context<'static> {
2828
/// use futures_test::task::noop_context;
2929
/// use pin_utils::pin_mut;
3030
///
31-
/// let mut future = async { 5 };
31+
/// let future = async { 5 };
3232
/// pin_mut!(future);
3333
///
3434
/// assert_eq!(future.poll(&mut noop_context()), Poll::Ready(5));

futures-test/src/task/noop_spawner.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ use futures_core::task::{Spawn, SpawnError};
1212
/// use futures_test::task::NoopSpawner;
1313
///
1414
/// let mut spawner = NoopSpawner::new();
15-
/// spawner.spawn(async { });
15+
/// spawner.spawn(async { })?;
16+
/// # Ok::<(), Box<dyn std::error::Error>>(())
1617
/// ```
1718
#[derive(Debug)]
1819
pub struct NoopSpawner {
@@ -51,7 +52,8 @@ impl Default for NoopSpawner {
5152
/// use futures_test::task::noop_spawner_mut;
5253
///
5354
/// let spawner = noop_spawner_mut();
54-
/// spawner.spawn(async { });
55+
/// spawner.spawn(async { })?;
56+
/// # Ok::<(), Box<dyn std::error::Error>>(())
5557
/// ```
5658
pub fn noop_spawner_mut() -> &'static mut NoopSpawner {
5759
Box::leak(Box::new(NoopSpawner::new()))

futures-test/src/task/panic_spawner.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ use futures_core::task::{Spawn, SpawnError};
1212
/// use futures_test::task::PanicSpawner;
1313
///
1414
/// let mut spawn = PanicSpawner::new();
15-
/// spawn.spawn(async { }); // Will panic
15+
/// spawn.spawn(async { })?; // Will panic
16+
/// # Ok::<(), Box<dyn std::error::Error>>(())
1617
/// ```
1718
#[derive(Debug)]
1819
pub struct PanicSpawner {
@@ -51,7 +52,8 @@ impl Default for PanicSpawner {
5152
/// use futures_test::task::panic_spawner_mut;
5253
///
5354
/// let spawner = panic_spawner_mut();
54-
/// spawner.spawn(async { }); // Will panic
55+
/// spawner.spawn(async { })?; // Will panic
56+
/// # Ok::<(), Box<dyn std::error::Error>>(())
5557
/// ```
5658
pub fn panic_spawner_mut() -> &'static mut PanicSpawner {
5759
Box::leak(Box::new(PanicSpawner::new()))

futures-test/src/task/panic_waker.rs

-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ pub fn panic_waker() -> Waker {
4747
///
4848
/// ```should_panic
4949
/// #![feature(async_await)]
50-
/// use futures::task;
5150
/// use futures_test::task::panic_waker_ref;
5251
///
5352
/// let waker = panic_waker_ref();

futures-test/src/task/record_spawner.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ use futures_core::task::{Spawn, SpawnError};
1212
/// use futures_test::task::RecordSpawner;
1313
///
1414
/// let mut recorder = RecordSpawner::new();
15-
/// recorder.spawn(async { });
15+
/// recorder.spawn(async { })?;
1616
/// assert_eq!(recorder.spawned().len(), 1);
17+
/// # Ok::<(), Box<dyn std::error::Error>>(())
1718
/// ```
1819
#[derive(Debug)]
1920
pub struct RecordSpawner {

futures-util/src/async_await/select_mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ macro_rules! document_select_macro {
2929
/// ```
3030
/// #![feature(async_await)]
3131
/// # futures::executor::block_on(async {
32-
/// use futures::future::{self, FutureExt};
32+
/// use futures::future;
3333
/// use futures::select;
3434
/// let mut a = future::ready(4);
3535
/// let mut b = future::empty::<()>();
@@ -45,7 +45,7 @@ macro_rules! document_select_macro {
4545
/// ```
4646
/// #![feature(async_await)]
4747
/// # futures::executor::block_on(async {
48-
/// use futures::future::{self, FutureExt};
48+
/// use futures::future;
4949
/// use futures::stream::{self, StreamExt};
5050
/// use futures::select;
5151
/// let mut st = stream::iter(vec![2]).fuse();
@@ -67,7 +67,7 @@ macro_rules! document_select_macro {
6767
/// ```
6868
/// #![feature(async_await)]
6969
/// # futures::executor::block_on(async {
70-
/// use futures::future::{self, FutureExt};
70+
/// use futures::future;
7171
/// use futures::select;
7272
/// let mut a_fut = future::ready(4);
7373
/// let mut b_fut = future::ready(6);

futures-util/src/compat/executor.rs

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ pub trait Executor01CompatExt: Executor01<Executor01Future> +
2323
///
2424
/// ```
2525
/// #![feature(async_await)]
26-
/// use futures::Future;
2726
/// use futures::task::SpawnExt;
2827
/// use futures::future::{FutureExt, TryFutureExt};
2928
/// use futures_util::compat::Executor01CompatExt;

futures-util/src/future/mod.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -397,9 +397,7 @@ pub trait FutureExt: Future {
397397
///
398398
/// # Examples
399399
///
400-
// TODO: minimize and open rust-lang/rust ticket, currently errors:
401-
// 'assertion failed: !value.has_escaping_regions()'
402-
/// ```ignore
400+
/// ```
403401
/// #![feature(async_await)]
404402
/// # futures::executor::block_on(async {
405403
/// use futures::future::{self, FutureExt, Ready};

futures-util/src/io/mod.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ pub trait AsyncReadExt: AsyncRead {
102102
///
103103
/// assert_eq!(bytes, 4);
104104
/// assert_eq!(writer.into_inner(), [1, 2, 3, 4, 0]);
105-
/// # Ok::<(), Box<std::error::Error>>(()) }).unwrap();
105+
/// # Ok::<(), Box<dyn std::error::Error>>(()) }).unwrap();
106106
/// ```
107107
fn copy_into<'a, W>(
108108
&'a mut self,
@@ -137,7 +137,7 @@ pub trait AsyncReadExt: AsyncRead {
137137
/// // `output.len()` bytes in a single read.
138138
/// assert_eq!(bytes, 4);
139139
/// assert_eq!(output, [1, 2, 3, 4, 0]);
140-
/// # Ok::<(), Box<std::error::Error>>(()) }).unwrap();
140+
/// # Ok::<(), Box<dyn std::error::Error>>(()) }).unwrap();
141141
/// ```
142142
fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Read<'a, Self>
143143
where Self: Unpin,
@@ -178,7 +178,7 @@ pub trait AsyncReadExt: AsyncRead {
178178
/// reader.read_exact(&mut output).await?;
179179
///
180180
/// assert_eq!(output, [1, 2, 3, 4]);
181-
/// # Ok::<(), Box<std::error::Error>>(()) }).unwrap();
181+
/// # Ok::<(), Box<dyn std::error::Error>>(()) }).unwrap();
182182
/// ```
183183
///
184184
/// ## EOF is hit before `buf` is filled
@@ -222,7 +222,7 @@ pub trait AsyncReadExt: AsyncRead {
222222
/// reader.read_to_end(&mut output).await?;
223223
///
224224
/// assert_eq!(output, vec![1, 2, 3, 4]);
225-
/// # Ok::<(), Box<std::error::Error>>(()) }).unwrap();
225+
/// # Ok::<(), Box<dyn std::error::Error>>(()) }).unwrap();
226226
/// ```
227227
fn read_to_end<'a>(
228228
&'a mut self,
@@ -262,7 +262,7 @@ pub trait AsyncReadExt: AsyncRead {
262262
///
263263
/// assert_eq!(buffer.into_inner(), [1, 2, 3, 4, 5, 6, 7, 8]);
264264
/// assert_eq!(writer.into_inner(), [5, 6, 7, 8, 0]);
265-
/// # Ok::<(), Box<std::error::Error>>(()) }).unwrap();
265+
/// # Ok::<(), Box<dyn std::error::Error>>(()) }).unwrap();
266266
/// ```
267267
fn split(self) -> (ReadHalf<Self>, WriteHalf<Self>)
268268
where Self: AsyncWrite + Sized,
@@ -301,15 +301,15 @@ pub trait AsyncWriteExt: AsyncWrite {
301301
/// let mut output = [0u8; 5];
302302
///
303303
/// {
304-
/// let mut writer = Cursor::new(&mut output[..]);
304+
/// let writer = Cursor::new(&mut output[..]);
305305
/// let mut buffered = AllowStdIo::new(BufWriter::new(writer));
306306
/// buffered.write_all(&[1, 2]).await?;
307307
/// buffered.write_all(&[3, 4]).await?;
308308
/// buffered.flush().await?;
309309
/// }
310310
///
311311
/// assert_eq!(output, [1, 2, 3, 4, 0]);
312-
/// # Ok::<(), Box<std::error::Error>>(()) }).unwrap();
312+
/// # Ok::<(), Box<dyn std::error::Error>>(()) }).unwrap();
313313
/// ```
314314
fn flush(&mut self) -> Flush<'_, Self>
315315
where Self: Unpin,
@@ -365,7 +365,7 @@ pub trait AsyncWriteExt: AsyncWrite {
365365
/// writer.write_all(&[1, 2, 3, 4]).await?;
366366
///
367367
/// assert_eq!(writer.into_inner(), [1, 2, 3, 4, 0]);
368-
/// # Ok::<(), Box<std::error::Error>>(()) }).unwrap();
368+
/// # Ok::<(), Box<dyn std::error::Error>>(()) }).unwrap();
369369
/// ```
370370
fn write_all<'a>(&'a mut self, buf: &'a [u8]) -> WriteAll<'a, Self>
371371
where Self: Unpin,
@@ -445,7 +445,7 @@ pub trait AsyncBufReadExt: AsyncBufRead {
445445
/// let num_bytes = cursor.read_until(b'-', &mut buf).await?;
446446
/// assert_eq!(num_bytes, 0);
447447
/// assert_eq!(buf, b"");
448-
/// # Ok::<(), Box<std::error::Error>>(()) }).unwrap();
448+
/// # Ok::<(), Box<dyn std::error::Error>>(()) }).unwrap();
449449
/// ```
450450
fn read_until<'a>(
451451
&'a mut self,
@@ -508,7 +508,7 @@ pub trait AsyncBufReadExt: AsyncBufRead {
508508
/// let num_bytes = cursor.read_line(&mut buf).await?;
509509
/// assert_eq!(num_bytes, 0);
510510
/// assert_eq!(buf, "");
511-
/// # Ok::<(), Box<std::error::Error>>(()) }).unwrap();
511+
/// # Ok::<(), Box<dyn std::error::Error>>(()) }).unwrap();
512512
/// ```
513513
fn read_line<'a>(&'a mut self, buf: &'a mut String) -> ReadLine<'a, Self>
514514
where Self: Unpin,
@@ -548,7 +548,7 @@ pub trait AsyncBufReadExt: AsyncBufRead {
548548
/// assert_eq!(lines_stream.next().await, Some(String::from("ipsum")));
549549
/// assert_eq!(lines_stream.next().await, Some(String::from("dolor")));
550550
/// assert_eq!(lines_stream.next().await, None);
551-
/// # Ok::<(), Box<std::error::Error>>(()) }).unwrap();
551+
/// # Ok::<(), Box<dyn std::error::Error>>(()) }).unwrap();
552552
/// ```
553553
fn lines(self) -> Lines<Self>
554554
where Self: Sized,

futures-util/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#![warn(missing_docs, missing_debug_implementations, rust_2018_idioms, unreachable_pub)]
1010
#![warn(clippy::all)]
1111

12+
#![doc(test(attr(deny(warnings), allow(dead_code, unused_assignments, unused_variables))))]
13+
1214
#![doc(html_root_url = "https://rust-lang-nursery.github.io/futures-api-docs/0.3.0-alpha.16/futures_util")]
1315

1416
#[cfg(all(feature = "cfg-target-has-atomic", not(feature = "nightly")))]

futures-util/src/stream/iter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ impl<I> Unpin for Iter<I> {}
2222
/// # futures::executor::block_on(async {
2323
/// use futures::stream::{self, StreamExt};
2424
///
25-
/// let mut stream = stream::iter(vec![17, 19]);
25+
/// let stream = stream::iter(vec![17, 19]);
2626
/// assert_eq!(vec![17, 19], stream.collect::<Vec<i32>>().await);
2727
/// # });
2828
/// ```

futures-util/src/stream/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -944,14 +944,14 @@ pub trait StreamExt: Stream {
944944
/// let stream_of_futures = stream::iter(vec![recv_one, recv_two]);
945945
/// let mut buffered = stream_of_futures.buffer_unordered(10);
946946
///
947-
/// send_two.send(2i32);
947+
/// send_two.send(2i32)?;
948948
/// assert_eq!(buffered.next().await, Some(Ok(2i32)));
949949
///
950-
/// send_one.send(1i32);
950+
/// send_one.send(1i32)?;
951951
/// assert_eq!(buffered.next().await, Some(Ok(1i32)));
952952
///
953953
/// assert_eq!(buffered.next().await, None);
954-
/// # })
954+
/// # Ok::<(), i32>(()) }).unwrap();
955955
/// ```
956956
#[cfg_attr(
957957
feature = "cfg-target-has-atomic",

futures-util/src/stream/once.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use pin_utils::unsafe_pinned;
1212
/// use futures::future;
1313
/// use futures::stream::{self, StreamExt};
1414
///
15-
/// let mut stream = stream::once(future::ready(17));
15+
/// let stream = stream::once(future::ready(17));
1616
/// let collected = stream.collect::<Vec<i32>>().await;
1717
/// assert_eq!(collected, vec![17]);
1818
/// # });

futures-util/src/stream/repeat.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub struct Repeat<T> {
2020
/// # futures::executor::block_on(async {
2121
/// use futures::stream::{self, StreamExt};
2222
///
23-
/// let mut stream = stream::repeat(9);
23+
/// let stream = stream::repeat(9);
2424
/// assert_eq!(vec![9, 9, 9], stream.take(3).collect::<Vec<i32>>().await);
2525
/// # });
2626
/// ```

0 commit comments

Comments
 (0)