From 4e312c49e54f7efe862f9dc937aa509228b8d774 Mon Sep 17 00:00:00 2001 From: Josh McKinney Date: Thu, 17 Oct 2024 21:08:16 -0700 Subject: [PATCH 1/4] runtime: fix stability feature flags for docs Fixes: #6907 --- tokio/src/lib.rs | 4 +++- tokio/src/runtime/builder.rs | 2 ++ tokio/src/runtime/mod.rs | 5 +++-- tokio/src/runtime/runtime.rs | 1 + tokio/src/runtime/task/mod.rs | 1 - 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/tokio/src/lib.rs b/tokio/src/lib.rs index bd85e28510f..9bac62c4daa 100644 --- a/tokio/src/lib.rs +++ b/tokio/src/lib.rs @@ -351,8 +351,10 @@ //! - [`task::Builder`] //! - Some methods on [`task::JoinSet`] //! - [`runtime::RuntimeMetrics`] +//! - [`runtime::Builder::on_task_spawn`] +//! - [`runtime::Builder::on_task_terminate`] //! - [`runtime::Builder::unhandled_panic`] -//! - [`task::Id`] +//! - [`runtime::TaskMeta`] //! //! This flag enables **unstable** features. The public API of these features //! may break in 1.x releases. To enable these features, the `--cfg diff --git a/tokio/src/runtime/builder.rs b/tokio/src/runtime/builder.rs index 4d35120b1f9..8ac9734cabf 100644 --- a/tokio/src/runtime/builder.rs +++ b/tokio/src/runtime/builder.rs @@ -728,6 +728,7 @@ impl Builder { /// # } /// ``` #[cfg(all(not(loom), tokio_unstable))] + #[cfg_attr(docsrs, doc(cfg(all(not(loom), tokio_unstable))))] pub fn on_task_spawn(&mut self, f: F) -> &mut Self where F: Fn(&TaskMeta<'_>) + Send + Sync + 'static, @@ -770,6 +771,7 @@ impl Builder { /// # } /// ``` #[cfg(all(not(loom), tokio_unstable))] + #[cfg_attr(docsrs, doc(cfg(all(not(loom), tokio_unstable))))] pub fn on_task_terminate(&mut self, f: F) -> &mut Self where F: Fn(&TaskMeta<'_>) + Send + Sync + 'static, diff --git a/tokio/src/runtime/mod.rs b/tokio/src/runtime/mod.rs index c8efbe2f1cd..6f1dfba753c 100644 --- a/tokio/src/runtime/mod.rs +++ b/tokio/src/runtime/mod.rs @@ -384,8 +384,9 @@ cfg_rt! { mod task_hooks; pub(crate) use task_hooks::{TaskHooks, TaskCallback}; - #[cfg(tokio_unstable)] - pub use task_hooks::TaskMeta; + cfg_unstable! { + pub use task_hooks::TaskMeta; + } #[cfg(not(tokio_unstable))] pub(crate) use task_hooks::TaskMeta; diff --git a/tokio/src/runtime/runtime.rs b/tokio/src/runtime/runtime.rs index 4b22ae9747c..242c37e0fbc 100644 --- a/tokio/src/runtime/runtime.rs +++ b/tokio/src/runtime/runtime.rs @@ -119,6 +119,7 @@ pub enum RuntimeFlavor { MultiThread, /// The flavor that executes tasks across multiple threads. #[cfg(tokio_unstable)] + #[cfg_attr(docsrs, doc(cfg(tokio_unstable)))] MultiThreadAlt, } diff --git a/tokio/src/runtime/task/mod.rs b/tokio/src/runtime/task/mod.rs index 6164bef906a..33f54003d38 100644 --- a/tokio/src/runtime/task/mod.rs +++ b/tokio/src/runtime/task/mod.rs @@ -391,7 +391,6 @@ impl Task { /// /// [task ID]: crate::task::Id #[cfg(tokio_unstable)] - #[cfg_attr(docsrs, doc(cfg(tokio_unstable)))] pub(crate) fn id(&self) -> crate::task::Id { // Safety: The header pointer is valid. unsafe { Header::get_id(self.raw.header_ptr()) } From c7003964cc6674f60bfe35bb4931cc16a9e9ab17 Mon Sep 17 00:00:00 2001 From: Josh McKinney Date: Fri, 18 Oct 2024 05:19:35 -0700 Subject: [PATCH 2/4] remove loom from doc attr Co-authored-by: Alice Ryhl --- tokio/src/runtime/builder.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tokio/src/runtime/builder.rs b/tokio/src/runtime/builder.rs index 8ac9734cabf..5d1490e91df 100644 --- a/tokio/src/runtime/builder.rs +++ b/tokio/src/runtime/builder.rs @@ -728,7 +728,7 @@ impl Builder { /// # } /// ``` #[cfg(all(not(loom), tokio_unstable))] - #[cfg_attr(docsrs, doc(cfg(all(not(loom), tokio_unstable))))] + #[cfg_attr(docsrs, doc(cfg(tokio_unstable)))] pub fn on_task_spawn(&mut self, f: F) -> &mut Self where F: Fn(&TaskMeta<'_>) + Send + Sync + 'static, From 12f55c55e06e2071ef3094d3ab76a4c06b595459 Mon Sep 17 00:00:00 2001 From: Josh McKinney Date: Tue, 22 Oct 2024 01:50:07 -0700 Subject: [PATCH 3/4] add unstable messaging --- tokio/src/runtime/builder.rs | 12 ++++++++++++ tokio/src/runtime/task_hooks.rs | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/tokio/src/runtime/builder.rs b/tokio/src/runtime/builder.rs index 5d1490e91df..1fd20bdc60b 100644 --- a/tokio/src/runtime/builder.rs +++ b/tokio/src/runtime/builder.rs @@ -706,6 +706,12 @@ impl Builder { /// /// This *does not* support [`LocalSet`](crate::task::LocalSet) at this time. /// + /// **Note**: This is an [unstable API][unstable]. The public API of this type + /// may break in 1.x releases. See [the documentation on unstable + /// features][unstable] for details. + /// + /// [unstable]: crate#unstable-features + /// /// # Examples /// /// ``` @@ -749,6 +755,12 @@ impl Builder { /// /// This *does not* support [`LocalSet`](crate::task::LocalSet) at this time. /// + /// **Note**: This is an [unstable API][unstable]. The public API of this type + /// may break in 1.x releases. See [the documentation on unstable + /// features][unstable] for details. + /// + /// [unstable]: crate#unstable-features + /// /// # Examples /// /// ``` diff --git a/tokio/src/runtime/task_hooks.rs b/tokio/src/runtime/task_hooks.rs index d30a8039a36..bc505ed16b4 100644 --- a/tokio/src/runtime/task_hooks.rs +++ b/tokio/src/runtime/task_hooks.rs @@ -15,6 +15,12 @@ pub(crate) struct TaskHooks { } /// Task metadata supplied to user-provided hooks for task events. +/// +/// **Note**: This is an [unstable API][unstable]. The public API of this type +/// may break in 1.x releases. See [the documentation on unstable +/// features][unstable] for details. +/// +/// [unstable]: crate#unstable-features #[allow(missing_debug_implementations)] #[cfg_attr(not(tokio_unstable), allow(unreachable_pub))] pub struct TaskMeta<'a> { From a6e83b8588b5676af4b0ca4597e9a623c2970f28 Mon Sep 17 00:00:00 2001 From: Josh McKinney Date: Tue, 22 Oct 2024 01:53:42 -0700 Subject: [PATCH 4/4] remove loom feature flag from docs --- tokio/src/runtime/builder.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tokio/src/runtime/builder.rs b/tokio/src/runtime/builder.rs index 1fd20bdc60b..8f3ed291223 100644 --- a/tokio/src/runtime/builder.rs +++ b/tokio/src/runtime/builder.rs @@ -783,7 +783,7 @@ impl Builder { /// # } /// ``` #[cfg(all(not(loom), tokio_unstable))] - #[cfg_attr(docsrs, doc(cfg(all(not(loom), tokio_unstable))))] + #[cfg_attr(docsrs, doc(cfg(tokio_unstable)))] pub fn on_task_terminate(&mut self, f: F) -> &mut Self where F: Fn(&TaskMeta<'_>) + Send + Sync + 'static,