Skip to content

Commit

Permalink
fix(turbo-tasks): Implement TaskInput for ResolvedVc`
Browse files Browse the repository at this point in the history
  • Loading branch information
bgw committed Oct 4, 2024
1 parent c2bc0e1 commit 78e4efa
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion turbopack/crates/turbo-tasks/src/task/task_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ use std::{any::Any, fmt::Debug, future::Future, hash::Hash, time::Duration};
use anyhow::Result;
use serde::{Deserialize, Serialize};

use crate::{MagicAny, RcStr, TaskId, TransientInstance, TransientValue, Value, ValueTypeId, Vc};
use crate::{
MagicAny, RcStr, ResolvedVc, TaskId, TransientInstance, TransientValue, Value, ValueTypeId, Vc,
};

/// Trait to implement in order for a type to be accepted as a
/// [`#[turbo_tasks::function]`][crate::function] argument.
Expand Down Expand Up @@ -108,6 +110,25 @@ where
}
}

// `TaskInput` isn't needed/used for a bare `ResolvedVc`, as we'll expose `ResolvedVc` arguments as
// `Vc`, but it is useful for structs that contain `ResolvedVc` and want to derive `TaskInput`.
impl<T> TaskInput for ResolvedVc<T>
where
T: Send,
{
fn is_resolved(&self) -> bool {
true
}

fn is_transient(&self) -> bool {
self.node.is_transient()
}

async fn resolve(&self) -> Result<Self> {
Ok(*self)
}
}

impl<T> TaskInput for Value<T>
where
T: Any
Expand Down

0 comments on commit 78e4efa

Please sign in to comment.