From 4d2ee3df8aca3244c387b52854f9170178ec59e8 Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Mon, 16 May 2022 09:12:19 -0700 Subject: [PATCH 1/2] task: add `#[track_caller]` to `JoinSet` spawn methods This should ensure that the spawned tasks have correct spawn locations. --- tokio/src/task/join_set.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tokio/src/task/join_set.rs b/tokio/src/task/join_set.rs index d036fcc3cda..42f55a034cc 100644 --- a/tokio/src/task/join_set.rs +++ b/tokio/src/task/join_set.rs @@ -81,6 +81,7 @@ impl JoinSet { /// This method panics if called outside of a Tokio runtime. /// /// [`AbortHandle`]: crate::task::AbortHandle + #[track_caller] pub fn spawn(&mut self, task: F) -> AbortHandle where F: Future, @@ -95,6 +96,7 @@ impl JoinSet { /// cancel the task. /// /// [`AbortHandle`]: crate::task::AbortHandle + #[track_caller] pub fn spawn_on(&mut self, task: F, handle: &Handle) -> AbortHandle where F: Future, @@ -114,6 +116,7 @@ impl JoinSet { /// /// [`LocalSet`]: crate::task::LocalSet /// [`AbortHandle`]: crate::task::AbortHandle + #[track_caller] pub fn spawn_local(&mut self, task: F) -> AbortHandle where F: Future, @@ -128,6 +131,7 @@ impl JoinSet { /// /// [`LocalSet`]: crate::task::LocalSet /// [`AbortHandle`]: crate::task::AbortHandle + #[track_caller] pub fn spawn_local_on(&mut self, task: F, local_set: &LocalSet) -> AbortHandle where F: Future, From 97627f5bc149554f72d4480e68782eb7a7520ac3 Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Mon, 16 May 2022 09:14:00 -0700 Subject: [PATCH 2/2] util: add missing `#[track_caller]`s to `JoinMap` Signed-off-by: Eliza Weisman --- tokio-util/src/task/join_map.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tokio-util/src/task/join_map.rs b/tokio-util/src/task/join_map.rs index 41c82f448ab..299c92faed3 100644 --- a/tokio-util/src/task/join_map.rs +++ b/tokio-util/src/task/join_map.rs @@ -285,6 +285,7 @@ where /// This method panics if called outside of a Tokio runtime. /// /// [`join_one`]: Self::join_one + #[track_caller] pub fn spawn(&mut self, key: K, task: F) where F: Future, @@ -304,6 +305,7 @@ where /// *not* return a cancelled [`JoinError`] for that task. /// /// [`join_one`]: Self::join_one + #[track_caller] pub fn spawn_on(&mut self, key: K, task: F, handle: &Handle) where F: Future, @@ -328,6 +330,7 @@ where /// /// [`LocalSet`]: tokio::task::LocalSet /// [`join_one`]: Self::join_one + #[track_caller] pub fn spawn_local(&mut self, key: K, task: F) where F: Future, @@ -347,6 +350,7 @@ where /// /// [`LocalSet`]: tokio::task::LocalSet /// [`join_one`]: Self::join_one + #[track_caller] pub fn spawn_local_on(&mut self, key: K, task: F, local_set: &LocalSet) where F: Future,