diff --git a/crates/gpui2/src/executor.rs b/crates/gpui2/src/executor.rs index b6fd5b2318..b7e3610283 100644 --- a/crates/gpui2/src/executor.rs +++ b/crates/gpui2/src/executor.rs @@ -68,7 +68,8 @@ impl Future for Task { } } } - +type AnyLocalFuture = Pin>>; +type AnyFuture = Pin>>; impl BackgroundExecutor { pub fn new(dispatcher: Arc) -> Self { Self { dispatcher } @@ -81,10 +82,16 @@ impl BackgroundExecutor { R: Send + 'static, { let dispatcher = self.dispatcher.clone(); - let (runnable, task) = - async_task::spawn(future, move |runnable| dispatcher.dispatch(runnable)); - runnable.schedule(); - Task::Spawned(task) + fn inner( + dispatcher: Arc, + future: AnyFuture, + ) -> Task { + let (runnable, task) = + async_task::spawn(future, move |runnable| dispatcher.dispatch(runnable)); + runnable.schedule(); + Task::Spawned(task) + } + inner::(dispatcher, Box::pin(future)) } #[cfg(any(test, feature = "test-support"))] @@ -243,11 +250,17 @@ impl ForegroundExecutor { R: 'static, { let dispatcher = self.dispatcher.clone(); - let (runnable, task) = async_task::spawn_local(future, move |runnable| { - dispatcher.dispatch_on_main_thread(runnable) - }); - runnable.schedule(); - Task::Spawned(task) + fn inner( + dispatcher: Arc, + future: AnyLocalFuture, + ) -> Task { + let (runnable, task) = async_task::spawn_local(future, move |runnable| { + dispatcher.dispatch_on_main_thread(runnable) + }); + runnable.schedule(); + Task::Spawned(task) + } + inner::(dispatcher, Box::pin(future)) } }