diff --git a/tokio/src/lib.rs b/tokio/src/lib.rs index b9ba0720b..804d0bf13 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`] +//! - [`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 //! 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 35d53bea2..287f072ac 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 279deaec1..bd343876a 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 f56282ce2..f1683f7e0 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 e85c54b3c..ecfa9e27b 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 08455d34b..20d492721 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;