Skip to content

Commit 0015399

Browse files
committed
Attempt to fix all documentation warnings from rustdoc.
I attempted to fix all documentation warnings in futures-rs. All of these refer to failing cross- references. Note that it's hard to verify as there is still alot of warnings from dependencies like rand and from what I suspect to be std, but it's unclear, since rustdoc doesn't mark the origin of the warnings. See: rust-lang/rust#59367 and rust-lang/rust#55907 The fixes here contain several TODO's, for two main reasons: - false positive warnings from rustdoc, where rustdoc generates a correct link but still issues a warning - places where I have been obliged to put a link to an html file because I didn't manage to make rustdoc generate a correct link from a path. It would be nice if people verified that commits don't throw warnings before merging, even in rustdoc. Especially so because rustdoc does not hide warnings in dependencies right now, even when called with `--no-deps`. That means that any warnings thrown by futures-rs will bother every single dev that has a (indirect) dependency on futures-rs and runs rustdoc.
1 parent 50f3f71 commit 0015399

File tree

7 files changed

+25
-10
lines changed

7 files changed

+25
-10
lines changed

futures-util/src/future/select.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use futures_core::future::Future;
33
use futures_core::task::{Context, Poll};
44
use crate::future::Either;
55

6-
/// Future for the [`select`](super::FutureExt::select) function.
6+
/// Future for the [`select()`] function.
77
#[must_use = "futures do nothing unless polled"]
88
#[derive(Debug)]
99
pub struct Select<A: Unpin, B: Unpin> {

futures-util/src/io/seek.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ use futures_core::task::{Context, Poll};
44
use std::io;
55
use std::pin::Pin;
66

7-
/// Future for the [`seek`](super::SeekExt::seek) method.
7+
// TODO: Currently this throws a warning, but it's a false positive as it generates a
8+
// correct link. See: https://github.com/rust-lang/rust/issues/55907
9+
// Verify everything works fine here when that get's resolved.
10+
//
11+
/// Future for the [`seek`](AsyncSeekExt::seek) method.
812
#[derive(Debug)]
913
pub struct Seek<'a, S: ?Sized + Unpin> {
1014
seek: &'a mut S,

futures-util/src/stream/enumerate.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ use futures_core::task::{Context, Poll};
44
use futures_sink::Sink;
55
use pin_utils::{unsafe_pinned, unsafe_unpinned};
66

7-
/// Stream for the [`enumerate`](super::EnumerateExt::enumerate) method.
7+
// TODO: rustdoc false positive warning about being unable to resolve: StreamExt::enumerate
8+
//
9+
/// Stream for the [`enumerate`](StreamExt::enumerate) method.
810
#[derive(Debug)]
911
#[must_use = "streams do nothing unless polled"]
1012
pub struct Enumerate<St: Stream> {

futures-util/src/stream/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,7 @@ pub trait StreamExt: Stream {
11001100
///
11011101
/// This is similar to the [`next`][StreamExt::next] method, but it won't
11021102
/// resolve to [`None`] if used on an empty [`Stream`]. Instead, the
1103-
/// returned future type will return [`true`] from
1103+
/// returned future type will return `true` from
11041104
/// [`FusedFuture::is_terminated`][] when the [`Stream`] is empty, allowing
11051105
/// [`select_next_some`][StreamExt::select_next_some] to be easily used with
11061106
/// the [`select!`] macro.

futures-util/src/stream/select.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use core::pin::Pin;
33
use futures_core::stream::{FusedStream, Stream};
44
use futures_core::task::{Context, Poll};
55

6-
/// Stream for the [`select`] function.
6+
/// Stream for the [`select()`] function.
77
#[derive(Debug)]
88
#[must_use = "streams do nothing unless polled"]
99
pub struct Select<St1, St2> {

futures-util/src/task/waker_ref.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ use core::marker::PhantomData;
66
use core::ops::Deref;
77
use core::task::{Waker, RawWaker, RawWakerVTable};
88

9+
// TODO: The link to Waker below points to futures::task::Waker and not to std. Is that a
10+
// bug in rustdoc?
11+
//
912
/// A [`Waker`](::std::task::Waker) that is only valid for a given lifetime.
1013
///
1114
/// Note: this type implements [`Deref<Target = Waker>`](::std::ops::Deref),
@@ -42,10 +45,10 @@ impl Deref for WakerRef<'_> {
4245
unsafe fn noop(_data: *const ()) {}
4346

4447
/// Creates a reference to a [`Waker`](::std::task::Waker)
45-
/// from a local [`wake`](::std::task::Wake).
48+
/// from a local [`ArcWake`].
4649
///
4750
/// The resulting [`Waker`](::std::task::Waker) will call
48-
/// [`wake.wake()`](::std::task::Wake::wake) if awoken.
51+
/// [`ArcWake.wake()`](ArcWake::wake) if awoken.
4952
#[inline]
5053
pub fn waker_ref<W>(wake: &Arc<W>) -> WakerRef<'_>
5154
where

futures-util/src/try_stream/mod.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,9 @@ pub trait TryStreamExt: TryStream {
678678
TryBufferUnordered::new(self, n)
679679
}
680680

681-
/// A convenience method for calling [`TryStream::poll_next_unpin`] on [`Unpin`]
681+
// TODO: false positive warning from rustdoc. Verify once #43466 settles
682+
//
683+
/// A convenience method for calling [`poll_next_unpin`](StreamExt::poll_next_unpin) on [`Unpin`]
682684
/// stream types.
683685
fn try_poll_next_unpin(
684686
&mut self,
@@ -717,9 +719,13 @@ pub trait TryStreamExt: TryStream {
717719
Compat::new(self)
718720
}
719721

720-
/// Adapter that converts this stream into an [`AsyncRead`].
722+
// TODO: I tried to make these doc links work, but failed to have the link work with
723+
// anything other than `trait.AsyncRead.html`. We should probably try again to use
724+
// paths once rustdoc has less issues.
725+
//
726+
/// Adapter that converts this stream into an [`AsyncRead`](trait.AsyncRead.html).
721727
///
722-
/// Note that because `into_async_read` moves the stream, the [`Stream`] type must be
728+
/// Note that because `into_async_read` moves the stream, the [`Stream`](trait.Stream.html) type must be
723729
/// [`Unpin`]. If you want to use `into_async_read` with a [`!Unpin`](Unpin) stream, you'll
724730
/// first have to pin the stream. This can be done by boxing the stream using [`Box::pin`]
725731
/// or pinning it to the stack using the `pin_mut!` macro from the `pin_utils` crate.

0 commit comments

Comments
 (0)