Unverified Commit 5cd0cce2 authored by Niklas Mischkulnig's avatar Niklas Mischkulnig Committed by GitHub

Turbopack: disambiguate `TaskInput::resolve` (#75661)

Disambiguate `TaskInput::resolve` from `Vc::resolve` and `ResolvedVc::resolve`.

Turns out there was only a single instance where `resolve()` turned out to be the wrong function anyway...
parent c4731a2e
...@@ -112,7 +112,7 @@ pub fn derive_task_input(input: TokenStream) -> TokenStream { ...@@ -112,7 +112,7 @@ pub fn derive_task_input(input: TokenStream) -> TokenStream {
quote! { quote! {
{ {
#( #(
let #fields = turbo_tasks::TaskInput::resolve(#fields).await?; let #fields = turbo_tasks::TaskInput::resolve_input(#fields).await?;
)* )*
Ok(#ident { #(#fields),* }) Ok(#ident { #(#fields),* })
} }
...@@ -126,7 +126,7 @@ pub fn derive_task_input(input: TokenStream) -> TokenStream { ...@@ -126,7 +126,7 @@ pub fn derive_task_input(input: TokenStream) -> TokenStream {
quote! { quote! {
{ {
#( #(
let #fields = turbo_tasks::TaskInput::resolve(#fields).await?; let #fields = turbo_tasks::TaskInput::resolve_input(#fields).await?;
)* )*
Ok(#ident(#(#fields),*)) Ok(#ident(#(#fields),*))
} }
...@@ -169,7 +169,7 @@ pub fn derive_task_input(input: TokenStream) -> TokenStream { ...@@ -169,7 +169,7 @@ pub fn derive_task_input(input: TokenStream) -> TokenStream {
#[allow(non_snake_case)] #[allow(non_snake_case)]
#[allow(unreachable_code)] // This can occur for enums with no variants. #[allow(unreachable_code)] // This can occur for enums with no variants.
#[allow(clippy::manual_async_fn)] // some impls need the manual return type to work :( #[allow(clippy::manual_async_fn)] // some impls need the manual return type to work :(
fn resolve( fn resolve_input(
&self, &self,
) -> impl ) -> impl
::std::future::Future<Output = turbo_tasks::Result<Self>> + ::std::future::Future<Output = turbo_tasks::Result<Self>> +
......
...@@ -518,7 +518,7 @@ impl TurboFn<'_> { ...@@ -518,7 +518,7 @@ impl TurboFn<'_> {
let (#(#exposed_input_idents,)*) = turbo_tasks::macro_helpers let (#(#exposed_input_idents,)*) = turbo_tasks::macro_helpers
::downcast_args_ref::<(#(#exposed_input_types,)*)>(magic_any); ::downcast_args_ref::<(#(#exposed_input_types,)*)>(magic_any);
let resolved = (#( let resolved = (#(
<_ as turbo_tasks::TaskInput>::resolve( <_ as turbo_tasks::TaskInput>::resolve_input(
#inline_input_idents #inline_input_idents
).await?, ).await?,
)*); )*);
......
...@@ -97,7 +97,7 @@ impl ArgMeta { ...@@ -97,7 +97,7 @@ impl ArgMeta {
fn resolve_functor_impl<T: MagicAny + TaskInput>(value: &dyn MagicAny) -> ResolveFuture<'_> { fn resolve_functor_impl<T: MagicAny + TaskInput>(value: &dyn MagicAny) -> ResolveFuture<'_> {
Box::pin(async { Box::pin(async {
let value = downcast_args_ref::<T>(value); let value = downcast_args_ref::<T>(value);
let resolved = value.resolve().await?; let resolved = value.resolve_input().await?;
Ok(Box::new(resolved) as Box<dyn MagicAny>) Ok(Box::new(resolved) as Box<dyn MagicAny>)
}) })
} }
......
...@@ -14,7 +14,7 @@ use crate::{ ...@@ -14,7 +14,7 @@ use crate::{
/// ///
/// See also [`ConcreteTaskInput`]. /// See also [`ConcreteTaskInput`].
pub trait TaskInput: Send + Sync + Clone + Debug + PartialEq + Eq + Hash { pub trait TaskInput: Send + Sync + Clone + Debug + PartialEq + Eq + Hash {
fn resolve(&self) -> impl Future<Output = Result<Self>> + Send + '_ { fn resolve_input(&self) -> impl Future<Output = Result<Self>> + Send + '_ {
async { Ok(self.clone()) } async { Ok(self.clone()) }
} }
fn is_resolved(&self) -> bool { fn is_resolved(&self) -> bool {
...@@ -62,10 +62,10 @@ where ...@@ -62,10 +62,10 @@ where
self.iter().any(TaskInput::is_transient) self.iter().any(TaskInput::is_transient)
} }
async fn resolve(&self) -> Result<Self> { async fn resolve_input(&self) -> Result<Self> {
let mut resolved = Vec::with_capacity(self.len()); let mut resolved = Vec::with_capacity(self.len());
for value in self { for value in self {
resolved.push(value.resolve().await?); resolved.push(value.resolve_input().await?);
} }
Ok(resolved) Ok(resolved)
} }
...@@ -89,9 +89,9 @@ where ...@@ -89,9 +89,9 @@ where
} }
} }
async fn resolve(&self) -> Result<Self> { async fn resolve_input(&self) -> Result<Self> {
match self { match self {
Some(value) => Ok(Some(value.resolve().await?)), Some(value) => Ok(Some(value.resolve_input().await?)),
None => Ok(None), None => Ok(None),
} }
} }
...@@ -109,7 +109,7 @@ where ...@@ -109,7 +109,7 @@ where
self.node.get_task_id().is_transient() self.node.get_task_id().is_transient()
} }
async fn resolve(&self) -> Result<Self> { async fn resolve_input(&self) -> Result<Self> {
Vc::resolve(*self).await Vc::resolve(*self).await
} }
} }
...@@ -128,7 +128,7 @@ where ...@@ -128,7 +128,7 @@ where
self.node.is_transient() self.node.is_transient()
} }
async fn resolve(&self) -> Result<Self> { async fn resolve_input(&self) -> Result<Self> {
Ok(*self) Ok(*self)
} }
} }
...@@ -228,10 +228,10 @@ where ...@@ -228,10 +228,10 @@ where
L: TaskInput, L: TaskInput,
R: TaskInput, R: TaskInput,
{ {
fn resolve(&self) -> impl Future<Output = Result<Self>> + Send + '_ { fn resolve_input(&self) -> impl Future<Output = Result<Self>> + Send + '_ {
self.as_ref().map_either( self.as_ref().map_either(
|l| async move { anyhow::Ok(Either::Left(l.resolve().await?)) }, |l| async move { anyhow::Ok(Either::Left(l.resolve_input().await?)) },
|r| async move { anyhow::Ok(Either::Right(r.resolve().await?)) }, |r| async move { anyhow::Ok(Either::Right(r.resolve_input().await?)) },
) )
} }
...@@ -264,15 +264,15 @@ macro_rules! tuple_impls { ...@@ -264,15 +264,15 @@ macro_rules! tuple_impls {
} }
#[allow(non_snake_case)] #[allow(non_snake_case)]
async fn resolve(&self) -> Result<Self> { async fn resolve_input(&self) -> Result<Self> {
let ($($name,)+) = self; let ($($name,)+) = self;
Ok(($($name.resolve().await?,)+)) Ok(($($name.resolve_input().await?,)+))
} }
} }
}; };
} }
// Implement `TaskInput` for all tuples of 1 to 16 elements. // Implement `TaskInput` for all tuples of 1 to 12 elements.
tuple_impls! { A } tuple_impls! { A }
tuple_impls! { A B } tuple_impls! { A B }
tuple_impls! { A B C } tuple_impls! { A B C }
......
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