Skip to content

Commit

Permalink
Refactor task arguments to be a single one (vercel/turborepo#8736)
Browse files Browse the repository at this point in the history
### Description

As preparation to pass a struct only, we change the task arguments to be
a single one

### Testing Instructions

<!--
  Give a quick description of steps to test your changes.
-->
  • Loading branch information
sokra authored Jul 17, 2024
1 parent cf49da0 commit fc3d226
Show file tree
Hide file tree
Showing 13 changed files with 157 additions and 2,207 deletions.
4 changes: 2 additions & 2 deletions crates/turbo-tasks-macros/src/derive/task_input_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ pub fn derive_task_input(input: TokenStream) -> TokenStream {
_ => return Err(anyhow::anyhow!("invalid discriminant for {}", stringify!(#ident))),
})
},
_ => Err(anyhow::anyhow!("invalid task input type, expected list")),
_ => Err(anyhow::anyhow!("invalid task input type, expected list (enum)")),
}
},
quote! {
Expand Down Expand Up @@ -155,7 +155,7 @@ pub fn derive_task_input(input: TokenStream) -> TokenStream {
#try_from_expansion
Ok(#ident #destructuring)
},
_ => Err(anyhow::anyhow!("invalid task input type, expected list")),
_ => Err(anyhow::anyhow!("invalid task input type, expected list (struct)")),
}
},
quote! {
Expand Down
6 changes: 3 additions & 3 deletions crates/turbo-tasks-macros/src/func.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ impl TurboFn {
*#trait_type_id_ident,
std::borrow::Cow::Borrowed(stringify!(#ident)),
#converted_this,
vec![#converted_inputs],
turbo_tasks::TaskInput::into_concrete((#converted_inputs)),
)
)
}
Expand All @@ -352,7 +352,7 @@ impl TurboFn {
turbo_tasks::dynamic_this_call(
*#native_function_id_ident,
#converted_this,
vec![#converted_inputs],
turbo_tasks::TaskInput::into_concrete((#converted_inputs)),
)
)
}
Expand All @@ -363,7 +363,7 @@ impl TurboFn {
<#output as turbo_tasks::task::TaskOutput>::try_from_raw_vc(
turbo_tasks::dynamic_call(
*#native_function_id_ident,
vec![#converted_inputs],
turbo_tasks::TaskInput::into_concrete((#converted_inputs)),
)
)
}
Expand Down
2 changes: 0 additions & 2 deletions crates/turbo-tasks-memory/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ mod edges_set;
mod gc;
mod map_guard;
mod memory_backend;
mod memory_backend_with_pg;
mod output;
mod task;
mod task_statistics;

pub use memory_backend::MemoryBackend;
pub use memory_backend_with_pg::MemoryBackendWithPersistedGraph;
pub use task_statistics::{TaskStatistics, TaskStatisticsApi};
8 changes: 4 additions & 4 deletions crates/turbo-tasks-memory/src/memory_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -548,20 +548,20 @@ impl Backend for MemoryBackend {
PersistentTaskType::ResolveNative {
fn_type: function_id,
this: _,
args: _,
arg: _,
}
| PersistentTaskType::Native {
fn_type: function_id,
this: _,
args: _,
arg: _,
} => {
stats.increment_cache_hit(*function_id);
}
PersistentTaskType::ResolveTrait {
trait_type,
method_name: name,
this,
args: _,
arg: _,
} => {
// HACK: Resolve the this argument (`self`) in order to attribute the cache hit
// to the concrete trait implementation, rather than the dynamic trait method.
Expand Down Expand Up @@ -595,7 +595,7 @@ impl Backend for MemoryBackend {
PersistentTaskType::Native {
fn_type: function_id,
this: _,
args: _,
arg: _,
} => {
stats.increment_cache_miss(*function_id);
}
Expand Down
Loading

0 comments on commit fc3d226

Please sign in to comment.