From 428cb1deccc9bca238842d0e9a423f585ba4403f Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Tue, 8 Feb 2022 16:02:13 -0800 Subject: [PATCH] task: fix missing `#[track_caller]` in `spawn_local` PR #3881 factored out the spawning of local tasks on a `LocalSet` into a function `spawn_local_inner`, so that the implementation could be shared with the `task::Builder` API. But, that PR neglected to add a `#[track_caller]` attribute to `spawn_local_inner`, so the `tracing` spans for local tasks are all generated with `spawn_local_inner` as their spawn location, rather than forwarding the actual spawn location from the calling function. This causes pretty useless results when using `tokio-console` with code that spawns a number of local tasks, such as Actix (https://old.reddit.com/r/rust/comments/snt5fq/can_tokioconsole_profile_actixrt/) This commit fixes the issue by adding the missing `#[track_caller]` attribute. --- tokio/src/task/local.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tokio/src/task/local.rs b/tokio/src/task/local.rs index 1beee6891ba..2dbd9706047 100644 --- a/tokio/src/task/local.rs +++ b/tokio/src/task/local.rs @@ -295,6 +295,8 @@ cfg_rt! { spawn_local_inner(future, None) } + + #[track_caller] pub(super) fn spawn_local_inner(future: F, name: Option<&str>) -> JoinHandle where F: Future + 'static, F::Output: 'static