diff --git a/tokio/src/macros/cfg.rs b/tokio/src/macros/cfg.rs index 3836aa78b9d..b6beb3d6952 100644 --- a/tokio/src/macros/cfg.rs +++ b/tokio/src/macros/cfg.rs @@ -373,6 +373,16 @@ macro_rules! cfg_trace { }; } +macro_rules! cfg_unstable { + ($($item:item)*) => { + $( + #[cfg(tokio_unstable)] + #[cfg_attr(docsrs, doc(cfg(tokio_unstable)))] + $item + )* + }; +} + macro_rules! cfg_not_trace { ($($item:item)*) => { $( diff --git a/tokio/src/runtime/task/mod.rs b/tokio/src/runtime/task/mod.rs index 15e36a0d897..2a492dc985d 100644 --- a/tokio/src/runtime/task/mod.rs +++ b/tokio/src/runtime/task/mod.rs @@ -135,6 +135,10 @@ //! poll call will notice it when the poll finishes, and the task is cancelled //! at that point. +// Some task infrastructure is here to support `JoinSet`, which is currently +// unstable. This should be removed once `JoinSet` is stabilized. +#![cfg_attr(not(tokio_unstable), allow(dead_code))] + mod core; use self::core::Cell; use self::core::Header; diff --git a/tokio/src/task/mod.rs b/tokio/src/task/mod.rs index 7d254190148..d532155a1fe 100644 --- a/tokio/src/task/mod.rs +++ b/tokio/src/task/mod.rs @@ -300,8 +300,10 @@ cfg_rt! { mod unconstrained; pub use unconstrained::{unconstrained, Unconstrained}; - mod join_set; - pub use join_set::JoinSet; + cfg_unstable! { + mod join_set; + pub use join_set::JoinSet; + } cfg_trace! { mod builder; diff --git a/tokio/src/util/mod.rs b/tokio/src/util/mod.rs index 41a3bce051f..618f5543802 100644 --- a/tokio/src/util/mod.rs +++ b/tokio/src/util/mod.rs @@ -44,8 +44,10 @@ pub(crate) mod linked_list; mod rand; cfg_rt! { - mod idle_notified_set; - pub(crate) use idle_notified_set::IdleNotifiedSet; + cfg_unstable! { + mod idle_notified_set; + pub(crate) use idle_notified_set::IdleNotifiedSet; + } mod wake; pub(crate) use wake::WakerRef; diff --git a/tokio/tests/async_send_sync.rs b/tokio/tests/async_send_sync.rs index c7e15c4775e..ea4445a27f1 100644 --- a/tokio/tests/async_send_sync.rs +++ b/tokio/tests/async_send_sync.rs @@ -434,13 +434,6 @@ 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_one(_): Send & Sync & !Unpin); -async_assert_fn!(tokio::task::JoinSet>::shutdown(_): Send & Sync & !Unpin); -async_assert_fn!(tokio::task::JoinSet>::join_one(_): !Send & !Sync & !Unpin); -async_assert_fn!(tokio::task::JoinSet>::shutdown(_): !Send & !Sync & !Unpin); -async_assert_fn!(tokio::task::JoinSet::join_one(_): 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); @@ -458,10 +451,20 @@ 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); +#[cfg(tokio_unstable)] +mod unstable { + use super::*; + async_assert_fn!(tokio::task::JoinSet>::join_one(_): Send & Sync & !Unpin); + async_assert_fn!(tokio::task::JoinSet>::shutdown(_): Send & Sync & !Unpin); + async_assert_fn!(tokio::task::JoinSet>::join_one(_): !Send & !Sync & !Unpin); + async_assert_fn!(tokio::task::JoinSet>::shutdown(_): !Send & !Sync & !Unpin); + async_assert_fn!(tokio::task::JoinSet::join_one(_): 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 574f216620e..66a2fbb021d 100644 --- a/tokio/tests/task_join_set.rs +++ b/tokio/tests/task_join_set.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(feature = "full")] +#![cfg(all(feature = "full", tokio_unstable))] use tokio::sync::oneshot; use tokio::task::JoinSet;