diff --git a/turbopack/crates/turbo-tasks/src/manager.rs b/turbopack/crates/turbo-tasks/src/manager.rs index 5b76872f120ce..6367a4139a414 100644 --- a/turbopack/crates/turbo-tasks/src/manager.rs +++ b/turbopack/crates/turbo-tasks/src/manager.rs @@ -259,13 +259,21 @@ pub trait TurboTasksBackendApiExt: TurboTasksBackendApi /// /// This function holds open a non-exclusive read lock that blocks writes, so `func` is expected /// to execute quickly in order to release the lock. - fn read_task_state(&self, func: impl FnOnce(&B::TaskState) -> T) -> T; + fn read_task_state(&self, func: impl FnOnce(&B::TaskState) -> T) -> T { + let mut out = None; + self.read_task_state_boxed(Box::new(|ts| out = Some(func(ts)))); + out.expect("write_task_state_boxed must call `func`") + } /// Allows modification of the [`Backend::TaskState`]. /// /// This function holds open a write lock, so `func` is expected to execute quickly in order to /// release the lock. - fn write_task_state(&self, func: impl FnOnce(&mut B::TaskState) -> T) -> T; + fn write_task_state(&self, func: impl FnOnce(&mut B::TaskState) -> T) -> T { + let mut out = None; + self.write_task_state_boxed(Box::new(|ts| out = Some(func(ts)))); + out.expect("write_task_state_boxed must call `func`") + } } impl TurboTasksBackendApiExt for TT @@ -273,17 +281,6 @@ where TT: TurboTasksBackendApi + ?Sized, B: Backend + 'static, { - fn read_task_state(&self, func: impl FnOnce(&B::TaskState) -> T) -> T { - let mut out = None; - self.read_task_state_boxed(Box::new(|ts| out = Some(func(ts)))); - out.expect("write_task_state_boxed must call `func`") - } - - fn write_task_state(&self, func: impl FnOnce(&mut B::TaskState) -> T) -> T { - let mut out = None; - self.write_task_state_boxed(Box::new(|ts| out = Some(func(ts)))); - out.expect("write_task_state_boxed must call `func`") - } } #[allow(clippy::manual_non_exhaustive)]