Unverified Commit dfea2b5e authored by Luke Sandberg's avatar Luke Sandberg Committed by GitHub

[turbopack] Simplify the implementations of TaskOutput::try_from_raw_vc (#80689)

Because RawVc is just a type erased version of Vc<T> we can have a single implementation.
parent f1f88e34
......@@ -144,10 +144,6 @@ impl TurboTasksCallApi for VcStorage {
}
impl TurboTasksApi for VcStorage {
fn pin(&self) -> Arc<dyn TurboTasksApi> {
self.this.upgrade().unwrap()
}
fn invalidate(&self, _task: TaskId) {
unreachable!()
}
......
......@@ -100,8 +100,6 @@ pub trait TurboTasksCallApi: Sync + Send {
/// This trait is needed because thread locals cannot contain an unresolved [`Backend`] type
/// parameter.
pub trait TurboTasksApi: TurboTasksCallApi + Sync + Send {
fn pin(&self) -> Arc<dyn TurboTasksApi>;
fn invalidate(&self, task: TaskId);
fn invalidate_with_reason(&self, task: TaskId, reason: StaticOrArc<dyn InvalidationReason>);
......@@ -1222,10 +1220,6 @@ impl<B: Backend + 'static> TurboTasksCallApi for TurboTasks<B> {
}
impl<B: Backend + 'static> TurboTasksApi for TurboTasks<B> {
fn pin(&self) -> Arc<dyn TurboTasksApi> {
self.pin()
}
#[instrument(level = Level::INFO, skip_all, name = "invalidate")]
fn invalidate(&self, task: TaskId) {
self.backend.invalidate_task(task, self);
......
......@@ -7,9 +7,14 @@ use crate::{RawVc, Vc};
/// Trait to implement in order for a type to be accepted as a
/// `turbo_tasks::function` return type.
pub trait TaskOutput: Send {
type Return;
type Return: ?Sized;
fn try_from_raw_vc(raw_vc: RawVc) -> Self::Return;
fn try_from_raw_vc(raw_vc: RawVc) -> Vc<Self::Return> {
Vc {
node: raw_vc,
_t: PhantomData,
}
}
fn try_into_raw_vc(self) -> Result<RawVc>;
}
......@@ -17,14 +22,7 @@ impl<T> TaskOutput for Vc<T>
where
T: Send + ?Sized,
{
type Return = Vc<T>;
fn try_from_raw_vc(raw_vc: RawVc) -> Self::Return {
Vc {
node: raw_vc,
_t: PhantomData,
}
}
type Return = T;
fn try_into_raw_vc(self) -> Result<RawVc> {
Ok(self.node)
......@@ -32,11 +30,7 @@ where
}
impl TaskOutput for () {
type Return = Vc<()>;
fn try_from_raw_vc(raw_vc: RawVc) -> Self::Return {
raw_vc.into()
}
type Return = ();
fn try_into_raw_vc(self) -> Result<RawVc> {
let unit = Vc::<()>::default();
......@@ -50,10 +44,6 @@ where
{
type Return = T::Return;
fn try_from_raw_vc(raw_vc: RawVc) -> Self::Return {
T::try_from_raw_vc(raw_vc)
}
fn try_into_raw_vc(self) -> Result<RawVc> {
self?.try_into_raw_vc()
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment