Skip to content

Commit

Permalink
remove ConcreteTaskInput in favor of the original rust datatypes
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Jul 17, 2024
1 parent d949ba2 commit f2892be
Show file tree
Hide file tree
Showing 66 changed files with 1,274 additions and 1,541 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 3 additions & 24 deletions crates/turbo-tasks-build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use turbo_tasks_macros_shared::{
get_impl_function_ident, get_native_function_ident, get_path_ident,
get_register_trait_methods_ident, get_register_value_type_ident,
get_trait_default_impl_function_ident, get_trait_impl_function_ident, get_trait_type_ident,
get_type_ident, GenericTypeInput, PrimitiveInput, ValueTraitArguments,
get_type_ident, GenericTypeInput, PrimitiveInput,
};

pub fn generate_register() {
Expand Down Expand Up @@ -361,10 +361,10 @@ impl<'a> RegisterContext<'a> {
}

fn process_trait_inner(&mut self, trait_item: &ItemTrait) -> Result<()> {
if let Some(attr) = trait_item
if trait_item
.attrs
.iter()
.find(|a| is_turbo_attribute(a, "value_trait"))
.any(|a| is_turbo_attribute(a, "value_trait"))
{
let trait_ident = &trait_item.ident;

Expand All @@ -388,16 +388,6 @@ impl<'a> RegisterContext<'a> {

let trait_type_ident = get_trait_type_ident(trait_ident);
self.register(trait_type_ident, self.get_global_name(&[trait_ident]))?;

let trait_args: ValueTraitArguments = parse_attr_args(attr)?.unwrap_or_default();
if trait_args.debug {
self.register_debug_impl(
&get_type_ident(&parse_quote! {
Box<dyn #trait_ident>
})
.unwrap(),
)?;
}
}
Ok(())
}
Expand Down Expand Up @@ -610,14 +600,3 @@ fn is_cfg_attribute(attr: &Attribute) -> bool {
.get_ident()
.is_some_and(|ident| ident == "cfg" || ident == "cfg_attr")
}

fn parse_attr_args<T>(attr: &Attribute) -> syn::Result<Option<T>>
where
T: syn::parse::Parse,
{
if attr.tokens.is_empty() {
Ok(None)
} else {
Ok(Some(attr.parse_args_with(T::parse)?))
}
}
1 change: 1 addition & 0 deletions crates/turbo-tasks-macros-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition = "2021"

[dev-dependencies]
anyhow = { workspace = true }
serde = { workspace = true }
tokio = { workspace = true }
turbo-tasks = { workspace = true }
turbo-tasks-memory = { workspace = true }
Expand Down
3 changes: 2 additions & 1 deletion crates/turbo-tasks-macros-tests/tests/task_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
//! However, we keep one test here as an integration test between the derive
//! macro and the `#[turbo_tasks::function]` macro.

use serde::{Deserialize, Serialize};
use turbo_tasks::{Completion, TaskInput, Vc};
use turbo_tasks_testing::{register, run};

register!();

#[derive(Clone, TaskInput)]
#[derive(Clone, TaskInput, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
struct OneUnnamedField(u32);

#[turbo_tasks::function]
Expand Down
Loading

0 comments on commit f2892be

Please sign in to comment.