diff --git a/crates/gpui/src/app.rs b/crates/gpui/src/app.rs index 828836efad..1408f44a93 100644 --- a/crates/gpui/src/app.rs +++ b/crates/gpui/src/app.rs @@ -1040,6 +1040,7 @@ impl App { /// Spawns the future returned by the given function on the thread pool. The closure will be invoked /// with [AsyncApp], which allows the application state to be accessed across await points. + #[track_caller] pub fn spawn(&self, f: impl FnOnce(AsyncApp) -> Fut) -> Task where Fut: Future + 'static, diff --git a/crates/gpui/src/app/async_context.rs b/crates/gpui/src/app/async_context.rs index 3e8f5cdd91..2375180e6f 100644 --- a/crates/gpui/src/app/async_context.rs +++ b/crates/gpui/src/app/async_context.rs @@ -172,6 +172,7 @@ impl AsyncApp { } /// Schedule a future to be polled in the background. + #[track_caller] pub fn spawn(&self, f: impl FnOnce(AsyncApp) -> Fut) -> Task where Fut: Future + 'static, @@ -297,6 +298,7 @@ impl AsyncWindowContext { /// Schedule a future to be executed on the main thread. This is used for collecting /// the results of background tasks and updating the UI. + #[track_caller] pub fn spawn(&self, f: impl FnOnce(AsyncWindowContext) -> Fut) -> Task where Fut: Future + 'static, diff --git a/crates/gpui/src/app/context.rs b/crates/gpui/src/app/context.rs index 5e892a6505..31f17cd9c8 100644 --- a/crates/gpui/src/app/context.rs +++ b/crates/gpui/src/app/context.rs @@ -183,6 +183,7 @@ impl<'a, T: 'static> Context<'a, T> { /// Spawn the future returned by the given function. /// The function is provided a weak handle to the entity owned by this context and a context that can be held across await points. /// The returned task must be held or detached. + #[track_caller] pub fn spawn(&self, f: impl FnOnce(WeakEntity, AsyncApp) -> Fut) -> Task where T: 'static, @@ -583,6 +584,7 @@ impl<'a, T: 'static> Context<'a, T> { /// The given callback is invoked with a [`WeakEntity`] to avoid leaking the view for a long-running process. /// It's also given an [`AsyncWindowContext`], which can be used to access the state of the view across await points. /// The returned future will be polled on the main thread. + #[track_caller] pub fn spawn_in( &self, window: &Window, diff --git a/crates/gpui/src/app/test_context.rs b/crates/gpui/src/app/test_context.rs index b14e572b50..7ad7623d33 100644 --- a/crates/gpui/src/app/test_context.rs +++ b/crates/gpui/src/app/test_context.rs @@ -317,6 +317,7 @@ impl TestAppContext { } /// Run the given task on the main thread. + #[track_caller] pub fn spawn(&self, f: impl FnOnce(AsyncApp) -> Fut) -> Task where Fut: Future + 'static, diff --git a/crates/gpui/src/window.rs b/crates/gpui/src/window.rs index 19254d280d..ffedaadb07 100644 --- a/crates/gpui/src/window.rs +++ b/crates/gpui/src/window.rs @@ -1307,6 +1307,7 @@ impl Window { /// Spawn the future returned by the given closure on the application thread pool. /// The closure is provided a handle to the current window and an `AsyncWindowContext` for /// use within your future. + #[track_caller] pub fn spawn(&self, cx: &App, f: impl FnOnce(AsyncWindowContext) -> Fut) -> Task where R: 'static,