From 6d8984b1909d19ca3a2d652720667941d6f91e31 Mon Sep 17 00:00:00 2001 From: Alice Ryhl Date: Thu, 1 Sep 2022 23:04:13 +0200 Subject: [PATCH 1/2] task: fix some doc and test things related to stabilizing `JoinSet` --- tokio/src/lib.rs | 6 ++++- tokio/src/macros/cfg.rs | 10 -------- tokio/src/runtime/tests/loom_join_set.rs | 1 - tokio/src/task/mod.rs | 10 ++++---- tokio/tests/async_send_sync.rs | 32 +++++++++++------------- tokio/tests/task_join_set.rs | 2 +- 6 files changed, 25 insertions(+), 36 deletions(-) diff --git a/tokio/src/lib.rs b/tokio/src/lib.rs index b9ba0720b51..9d0b7dfbbe3 100644 --- a/tokio/src/lib.rs +++ b/tokio/src/lib.rs @@ -349,7 +349,11 @@ //! Likewise, some parts of the API are only available with the same flag: //! //! - [`task::Builder`] -//! +//! - Some methods on [`task::JoinSet`] +//! - [`runtime::RuntimeMetrics`] +//! - [`tokio::runtime::Builder::unhandled_panic`] +//! - [`tokio::task::Id`] +//! //! This flag enables **unstable** features. The public API of these features //! may break in 1.x releases. To enable these features, the `--cfg //! tokio_unstable` argument must be passed to `rustc` when compiling. This diff --git a/tokio/src/macros/cfg.rs b/tokio/src/macros/cfg.rs index 35d53bea237..287f072acde 100644 --- a/tokio/src/macros/cfg.rs +++ b/tokio/src/macros/cfg.rs @@ -406,16 +406,6 @@ macro_rules! cfg_unstable { }; } -macro_rules! cfg_not_unstable { - ($($item:item)*) => { - $( - #[cfg(not(tokio_unstable))] - #[cfg_attr(docsrs, doc(cfg(not(tokio_unstable))))] - $item - )* - }; -} - macro_rules! cfg_not_trace { ($($item:item)*) => { $( diff --git a/tokio/src/runtime/tests/loom_join_set.rs b/tokio/src/runtime/tests/loom_join_set.rs index 279deaec17e..bd343876a26 100644 --- a/tokio/src/runtime/tests/loom_join_set.rs +++ b/tokio/src/runtime/tests/loom_join_set.rs @@ -1,4 +1,3 @@ -#![cfg(tokio_unstable)] use crate::runtime::Builder; use crate::task::JoinSet; diff --git a/tokio/src/task/mod.rs b/tokio/src/task/mod.rs index f56282ce201..f1683f7e07f 100644 --- a/tokio/src/task/mod.rs +++ b/tokio/src/task/mod.rs @@ -311,14 +311,14 @@ cfg_rt! { pub use join_set::JoinSet; pub use crate::runtime::task::AbortHandle; - cfg_not_unstable! { - mod join_set; - } + // Uses #[cfg(...)] instead of macro since the macro adds docsrs annotations. + #[cfg(not(tokio_unstable))] + mod join_set; + #[cfg(tokio_unstable)] + pub mod join_set; cfg_unstable! { pub use crate::runtime::task::Id; - - pub mod join_set; } cfg_trace! { diff --git a/tokio/tests/async_send_sync.rs b/tokio/tests/async_send_sync.rs index e85c54b3cc8..ecfa9e27b85 100644 --- a/tokio/tests/async_send_sync.rs +++ b/tokio/tests/async_send_sync.rs @@ -394,6 +394,14 @@ assert_value!(tokio::sync::watch::Ref<'_, YY>: !Send & Sync & Unpin); assert_value!(tokio::sync::watch::Sender: !Send & !Sync & Unpin); assert_value!(tokio::sync::watch::Sender: !Send & !Sync & Unpin); assert_value!(tokio::sync::watch::Sender: Send & Sync & Unpin); +assert_value!(tokio::task::JoinError: Send & Sync & Unpin); +assert_value!(tokio::task::JoinHandle: !Send & !Sync & Unpin); +assert_value!(tokio::task::JoinHandle: Send & Sync & Unpin); +assert_value!(tokio::task::JoinHandle: Send & Sync & Unpin); +assert_value!(tokio::task::JoinSet: !Send & !Sync & Unpin); +assert_value!(tokio::task::JoinSet: Send & Sync & Unpin); +assert_value!(tokio::task::JoinSet: Send & Sync & Unpin); +assert_value!(tokio::task::LocalSet: !Send & !Sync & Unpin); async_assert_fn!(tokio::sync::Barrier::wait(_): Send & Sync & !Unpin); async_assert_fn!(tokio::sync::Mutex::lock(_): !Send & !Sync & !Unpin); async_assert_fn!(tokio::sync::Mutex::lock_owned(_): !Send & !Sync & !Unpin); @@ -466,6 +474,12 @@ async_assert_fn!(tokio::sync::watch::Receiver::changed(_): Send & Sync & !Un async_assert_fn!(tokio::sync::watch::Sender::closed(_): !Send & !Sync & !Unpin); async_assert_fn!(tokio::sync::watch::Sender::closed(_): !Send & !Sync & !Unpin); async_assert_fn!(tokio::sync::watch::Sender::closed(_): Send & Sync & !Unpin); +async_assert_fn!(tokio::task::JoinSet>::join_next(_): Send & Sync & !Unpin); +async_assert_fn!(tokio::task::JoinSet>::shutdown(_): Send & Sync & !Unpin); +async_assert_fn!(tokio::task::JoinSet>::join_next(_): !Send & !Sync & !Unpin); +async_assert_fn!(tokio::task::JoinSet>::shutdown(_): !Send & !Sync & !Unpin); +async_assert_fn!(tokio::task::JoinSet::join_next(_): Send & Sync & !Unpin); +async_assert_fn!(tokio::task::JoinSet::shutdown(_): Send & Sync & !Unpin); async_assert_fn!(tokio::task::LocalKey>::scope(_, Cell, BoxFuture<()>): !Send & !Sync & !Unpin); async_assert_fn!(tokio::task::LocalKey>::scope(_, Cell, BoxFutureSend<()>): Send & !Sync & !Unpin); async_assert_fn!(tokio::task::LocalKey>::scope(_, Cell, BoxFutureSync<()>): Send & !Sync & !Unpin); @@ -479,24 +493,6 @@ async_assert_fn!(tokio::task::LocalSet::run_until(_, BoxFutureSync<()>): !Send & async_assert_fn!(tokio::task::unconstrained(BoxFuture<()>): !Send & !Sync & Unpin); async_assert_fn!(tokio::task::unconstrained(BoxFutureSend<()>): Send & !Sync & Unpin); async_assert_fn!(tokio::task::unconstrained(BoxFutureSync<()>): Send & Sync & Unpin); -assert_value!(tokio::task::JoinError: Send & Sync & Unpin); -assert_value!(tokio::task::JoinHandle: !Send & !Sync & Unpin); -assert_value!(tokio::task::JoinHandle: Send & Sync & Unpin); -assert_value!(tokio::task::JoinHandle: Send & Sync & Unpin); -#[cfg(tokio_unstable)] -mod unstable { - use super::*; - async_assert_fn!(tokio::task::JoinSet>::join_next(_): Send & Sync & !Unpin); - async_assert_fn!(tokio::task::JoinSet>::shutdown(_): Send & Sync & !Unpin); - async_assert_fn!(tokio::task::JoinSet>::join_next(_): !Send & !Sync & !Unpin); - async_assert_fn!(tokio::task::JoinSet>::shutdown(_): !Send & !Sync & !Unpin); - async_assert_fn!(tokio::task::JoinSet::join_next(_): Send & Sync & !Unpin); - async_assert_fn!(tokio::task::JoinSet::shutdown(_): Send & Sync & !Unpin); - assert_value!(tokio::task::JoinSet: Send & Sync & Unpin); - assert_value!(tokio::task::JoinSet: Send & Sync & Unpin); - assert_value!(tokio::task::JoinSet: !Send & !Sync & Unpin); - assert_value!(tokio::task::LocalSet: !Send & !Sync & Unpin); -} assert_value!(tokio::runtime::Builder: Send & Sync & Unpin); assert_value!(tokio::runtime::EnterGuard<'_>: Send & Sync & Unpin); diff --git a/tokio/tests/task_join_set.rs b/tokio/tests/task_join_set.rs index 08455d34b5a..20d4927212a 100644 --- a/tokio/tests/task_join_set.rs +++ b/tokio/tests/task_join_set.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", tokio_unstable))] +#![cfg(all(feature = "full"))] use tokio::sync::oneshot; use tokio::task::JoinSet; From 11c6621c0d749a7f7b142abbd58c56a7043e01ae Mon Sep 17 00:00:00 2001 From: Alice Ryhl Date: Thu, 1 Sep 2022 23:09:07 +0200 Subject: [PATCH 2/2] Update tokio/src/lib.rs --- tokio/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tokio/src/lib.rs b/tokio/src/lib.rs index 9d0b7dfbbe3..804d0bf1301 100644 --- a/tokio/src/lib.rs +++ b/tokio/src/lib.rs @@ -351,8 +351,8 @@ //! - [`task::Builder`] //! - Some methods on [`task::JoinSet`] //! - [`runtime::RuntimeMetrics`] -//! - [`tokio::runtime::Builder::unhandled_panic`] -//! - [`tokio::task::Id`] +//! - [`runtime::Builder::unhandled_panic`] +//! - [`task::Id`] //! //! This flag enables **unstable** features. The public API of these features //! may break in 1.x releases. To enable these features, the `--cfg