diff options
author | Alice Ryhl <alice@ryhl.io> | 2020-10-02 06:13:28 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-01 21:13:28 -0700 |
commit | 7ec6d88b21ea3e5531176f526a51dae0a4513025 (patch) | |
tree | 6b4f289567fce7033551910c684c8358da4a58d8 /tokio | |
parent | 13de30c53eb90a5453f1cecf47b188e254a293ac (diff) |
chore: make #[doc(hidden)] apis private (#2901)
Diffstat (limited to 'tokio')
-rw-r--r-- | tokio/src/fs/read_dir.rs | 3 | ||||
-rw-r--r-- | tokio/src/io/util/lines.rs | 3 | ||||
-rw-r--r-- | tokio/src/io/util/split.rs | 3 | ||||
-rw-r--r-- | tokio/src/macros/scoped_tls.rs | 2 | ||||
-rw-r--r-- | tokio/src/net/tcp/stream.rs | 10 | ||||
-rw-r--r-- | tokio/src/sync/oneshot.rs | 3 | ||||
-rw-r--r-- | tokio/src/sync/tests/loom_oneshot.rs | 6 | ||||
-rw-r--r-- | tokio/src/time/interval.rs | 3 | ||||
-rw-r--r-- | tokio/tests/sync_oneshot.rs | 13 | ||||
-rw-r--r-- | tokio/tests/time_interval.rs | 8 |
10 files changed, 36 insertions, 18 deletions
diff --git a/tokio/src/fs/read_dir.rs b/tokio/src/fs/read_dir.rs index f9b16c66..5af2dcaa 100644 --- a/tokio/src/fs/read_dir.rs +++ b/tokio/src/fs/read_dir.rs @@ -55,8 +55,7 @@ impl ReadDir { poll_fn(|cx| self.poll_next_entry(cx)).await } - #[doc(hidden)] - pub fn poll_next_entry(&mut self, cx: &mut Context<'_>) -> Poll<io::Result<Option<DirEntry>>> { + fn poll_next_entry(&mut self, cx: &mut Context<'_>) -> Poll<io::Result<Option<DirEntry>>> { loop { match self.0 { State::Idle(ref mut std) => { diff --git a/tokio/src/io/util/lines.rs b/tokio/src/io/util/lines.rs index ee27400c..b41f04a8 100644 --- a/tokio/src/io/util/lines.rs +++ b/tokio/src/io/util/lines.rs @@ -83,8 +83,7 @@ impl<R> Lines<R> where R: AsyncBufRead, { - #[doc(hidden)] - pub fn poll_next_line( + fn poll_next_line( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<io::Result<Option<String>>> { diff --git a/tokio/src/io/util/split.rs b/tokio/src/io/util/split.rs index f552ed50..492e26a6 100644 --- a/tokio/src/io/util/split.rs +++ b/tokio/src/io/util/split.rs @@ -65,8 +65,7 @@ impl<R> Split<R> where R: AsyncBufRead, { - #[doc(hidden)] - pub fn poll_next_segment( + fn poll_next_segment( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<io::Result<Option<Vec<u8>>>> { diff --git a/tokio/src/macros/scoped_tls.rs b/tokio/src/macros/scoped_tls.rs index 886f9d44..a00aae2f 100644 --- a/tokio/src/macros/scoped_tls.rs +++ b/tokio/src/macros/scoped_tls.rs @@ -23,9 +23,7 @@ macro_rules! scoped_thread_local { /// Type representing a thread local storage key corresponding to a reference /// to the type parameter `T`. pub(crate) struct ScopedKey<T> { - #[doc(hidden)] pub(crate) inner: &'static LocalKey<Cell<*const ()>>, - #[doc(hidden)] pub(crate) _marker: marker::PhantomData<T>, } diff --git a/tokio/src/net/tcp/stream.rs b/tokio/src/net/tcp/stream.rs index 99f77d41..f35f8b0c 100644 --- a/tokio/src/net/tcp/stream.rs +++ b/tokio/src/net/tcp/stream.rs @@ -192,9 +192,13 @@ impl TcpStream { Ok(TcpStream { io }) } - // Connects `TcpStream` asynchronously that may be built with a net2 `TcpBuilder`. - // - // This should be removed in favor of some in-crate TcpSocket builder API. + /// Connects `TcpStream` asynchronously that may be built with a net2 `TcpBuilder`. + /// + /// This function is intended to be replaced with some sort of TcpSocket builder. + /// See https://github.com/tokio-rs/tokio/issues/2902 + /// + /// Despite being hidden, this function is part of the public API of Tokio v0.3, but + /// will be removed in v1.0 in favor of a better design. #[doc(hidden)] pub async fn connect_std(stream: net::TcpStream, addr: &SocketAddr) -> io::Result<TcpStream> { let io = mio::net::TcpStream::connect_stream(stream, addr)?; diff --git a/tokio/src/sync/oneshot.rs b/tokio/src/sync/oneshot.rs index 32506bc3..951ab71d 100644 --- a/tokio/src/sync/oneshot.rs +++ b/tokio/src/sync/oneshot.rs @@ -196,8 +196,7 @@ impl<T> Sender<T> { Ok(()) } - #[doc(hidden)] // TODO: remove - pub fn poll_closed(&mut self, cx: &mut Context<'_>) -> Poll<()> { + fn poll_closed(&mut self, cx: &mut Context<'_>) -> Poll<()> { // Keep track of task budget let coop = ready!(crate::coop::poll_proceed(cx)); diff --git a/tokio/src/sync/tests/loom_oneshot.rs b/tokio/src/sync/tests/loom_oneshot.rs index dfa7459d..9729cfb7 100644 --- a/tokio/src/sync/tests/loom_oneshot.rs +++ b/tokio/src/sync/tests/loom_oneshot.rs @@ -75,8 +75,10 @@ impl Future for OnClose<'_> { type Output = bool; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<bool> { - let res = self.get_mut().tx.poll_closed(cx); - Ready(res.is_ready()) + let fut = self.get_mut().tx.closed(); + crate::pin!(fut); + + Ready(fut.poll(cx).is_ready()) } } diff --git a/tokio/src/time/interval.rs b/tokio/src/time/interval.rs index 5f05b2f9..1b443a36 100644 --- a/tokio/src/time/interval.rs +++ b/tokio/src/time/interval.rs @@ -122,8 +122,7 @@ pub struct Interval { } impl Interval { - #[doc(hidden)] // TODO: document - pub fn poll_tick(&mut self, cx: &mut Context<'_>) -> Poll<Instant> { + fn poll_tick(&mut self, cx: &mut Context<'_>) -> Poll<Instant> { // Wait for the delay to be done ready!(Pin::new(&mut self.delay).poll(cx)); diff --git a/tokio/tests/sync_oneshot.rs b/tokio/tests/sync_oneshot.rs index 13e526d4..195c2553 100644 --- a/tokio/tests/sync_oneshot.rs +++ b/tokio/tests/sync_oneshot.rs @@ -6,11 +6,24 @@ use tokio_test::*; use std::future::Future; use std::pin::Pin; +use std::task::{Context, Poll}; trait AssertSend: Send {} impl AssertSend for oneshot::Sender<i32> {} impl AssertSend for oneshot::Receiver<i32> {} +trait SenderExt { + fn poll_closed(&mut self, cx: &mut Context<'_>) -> Poll<()>; +} +impl<T> SenderExt for oneshot::Sender<T> { + fn poll_closed(&mut self, cx: &mut Context<'_>) -> Poll<()> { + tokio::pin! { + let fut = self.closed(); + } + fut.poll(cx) + } +} + #[test] fn send_recv() { let (tx, rx) = oneshot::channel(); diff --git a/tokio/tests/time_interval.rs b/tokio/tests/time_interval.rs index 1123681f..5ac6ae69 100644 --- a/tokio/tests/time_interval.rs +++ b/tokio/tests/time_interval.rs @@ -4,6 +4,7 @@ use tokio::time::{self, Duration, Instant}; use tokio_test::{assert_pending, assert_ready_eq, task}; +use std::future::Future; use std::task::Poll; #[tokio::test] @@ -58,7 +59,12 @@ async fn usage_stream() { } fn poll_next(interval: &mut task::Spawn<time::Interval>) -> Poll<Instant> { - interval.enter(|cx, mut interval| interval.poll_tick(cx)) + interval.enter(|cx, mut interval| { + tokio::pin! { + let fut = interval.tick(); + } + fut.poll(cx) + }) } fn ms(n: u64) -> Duration { |