diff --git a/tokio/src/runtime/task/abort.rs b/tokio/src/runtime/task/abort.rs index 899f54894..507973eb4 100644 --- a/tokio/src/runtime/task/abort.rs +++ b/tokio/src/runtime/task/abort.rs @@ -68,14 +68,7 @@ impl AbortHandle { /// Returns a [task ID] that uniquely identifies this task relative to other /// currently spawned tasks. /// - /// **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. - /// /// [task ID]: crate::task::Id - /// [unstable]: crate#unstable-features - #[cfg(tokio_unstable)] - #[cfg_attr(docsrs, doc(cfg(tokio_unstable)))] pub fn id(&self) -> super::Id { // Safety: The header pointer is valid. unsafe { Header::get_id(self.raw.header_ptr()) } diff --git a/tokio/src/runtime/task/id.rs b/tokio/src/runtime/task/id.rs index 9c3b1403e..63d01700b 100644 --- a/tokio/src/runtime/task/id.rs +++ b/tokio/src/runtime/task/id.rs @@ -15,14 +15,7 @@ use std::{fmt, num::NonZeroU64}; /// task via the [`task::try_id()`](crate::task::try_id()) and /// [`task::id()`](crate::task::id()) functions and from outside the task via /// the [`JoinHandle::id()`](crate::task::JoinHandle::id()) function. -/// -/// **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 -#[cfg_attr(docsrs, doc(cfg(all(feature = "rt", tokio_unstable))))] -#[cfg_attr(not(tokio_unstable), allow(unreachable_pub))] +#[cfg_attr(docsrs, doc(cfg(all(feature = "rt"))))] #[derive(Clone, Copy, Debug, Hash, Eq, PartialEq)] pub struct Id(pub(crate) NonZeroU64); @@ -35,13 +28,7 @@ pub struct Id(pub(crate) NonZeroU64); /// within a call to `block_on`. For a version of this function that doesn't /// panic, see [`task::try_id()`](crate::runtime::task::try_id()). /// -/// **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. -/// /// [task ID]: crate::task::Id -/// [unstable]: crate#unstable-features -#[cfg_attr(not(tokio_unstable), allow(unreachable_pub))] #[track_caller] pub fn id() -> Id { context::current_task_id().expect("Can't get a task id when not inside a task") @@ -54,13 +41,7 @@ pub fn id() -> Id { /// that it returns `None` rather than panicking if called outside of a task /// context. /// -/// **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. -/// /// [task ID]: crate::task::Id -/// [unstable]: crate#unstable-features -#[cfg_attr(not(tokio_unstable), allow(unreachable_pub))] #[track_caller] pub fn try_id() -> Option { context::current_task_id() diff --git a/tokio/src/runtime/task/join.rs b/tokio/src/runtime/task/join.rs index aad6094b5..086637a58 100644 --- a/tokio/src/runtime/task/join.rs +++ b/tokio/src/runtime/task/join.rs @@ -305,14 +305,7 @@ impl JoinHandle { /// Returns a [task ID] that uniquely identifies this task relative to other /// currently spawned tasks. /// - /// **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. - /// /// [task ID]: crate::task::Id - /// [unstable]: crate#unstable-features - #[cfg(tokio_unstable)] - #[cfg_attr(docsrs, doc(cfg(tokio_unstable)))] pub fn id(&self) -> super::Id { // Safety: The header pointer is valid. unsafe { Header::get_id(self.raw.header_ptr()) } diff --git a/tokio/src/task/mod.rs b/tokio/src/task/mod.rs index 05d95d2d5..86bc0eaae 100644 --- a/tokio/src/task/mod.rs +++ b/tokio/src/task/mod.rs @@ -359,9 +359,7 @@ cfg_rt! { #[cfg(tokio_unstable)] pub mod join_set; - cfg_unstable! { - pub use crate::runtime::task::{Id, id, try_id}; - } + pub use crate::runtime::task::{Id, id, try_id}; cfg_trace! { mod builder; diff --git a/tokio/tests/task_id.rs b/tokio/tests/task_id.rs index 574a050b0..c0aed66f1 100644 --- a/tokio/tests/task_id.rs +++ b/tokio/tests/task_id.rs @@ -1,22 +1,18 @@ #![allow(unknown_lints, unexpected_cfgs)] #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", tokio_unstable))] +#![cfg(feature = "full")] -#[cfg(not(target_os = "wasi"))] use std::error::Error; use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; -#[cfg(not(target_os = "wasi"))] -use tokio::runtime::{Builder, Runtime}; +use tokio::runtime::Runtime; use tokio::sync::oneshot; use tokio::task::{self, Id, LocalSet}; -#[cfg(not(target_os = "wasi"))] mod support { pub mod panic; } -#[cfg(not(target_os = "wasi"))] use support::panic::test_panic; #[tokio::test(flavor = "current_thread")] @@ -256,6 +252,8 @@ async fn task_id_nested_spawn_local() { #[cfg(not(target_os = "wasi"))] #[tokio::test(flavor = "multi_thread")] async fn task_id_block_in_place_block_on_spawn() { + use tokio::runtime::Builder; + task::spawn(async { let parent_id = task::id(); @@ -273,8 +271,8 @@ async fn task_id_block_in_place_block_on_spawn() { .unwrap(); } -#[cfg(not(target_os = "wasi"))] #[test] +#[cfg_attr(not(panic = "unwind"), ignore)] fn task_id_outside_task_panic_caller() -> Result<(), Box> { let panic_location_file = test_panic(|| { let _ = task::id(); @@ -286,8 +284,8 @@ fn task_id_outside_task_panic_caller() -> Result<(), Box> { Ok(()) } -#[cfg(not(target_os = "wasi"))] #[test] +#[cfg_attr(not(panic = "unwind"), ignore)] fn task_id_inside_block_on_panic_caller() -> Result<(), Box> { let panic_location_file = test_panic(|| { let rt = Runtime::new().unwrap();