Skip to content

Commit

Permalink
Merge 2f94004 into dd05689
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkirsz authored Aug 24, 2023
2 parents dd05689 + 2f94004 commit d4da097
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
12 changes: 12 additions & 0 deletions crates/turbo-tasks-macros/src/primitive_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,22 @@ pub fn primitive(input: TokenStream) -> TokenStream {
},
);

let value_default_impl = quote! {
#[turbo_tasks::value_impl]
impl turbo_tasks::ValueDefault for #ty {
#[turbo_tasks::function]
fn value_default() -> Vc<Self> {
Vc::cell(Default::default())
}
}
};

quote! {
#value_type_and_register

#value_debug_impl

#value_default_impl
}
.into()
}
9 changes: 3 additions & 6 deletions crates/turbo-tasks/src/primitives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ fn empty_string() -> Vc<String> {
}

impl Vc<String> {
#[deprecated(note = "use Default::default() instead")]
#[inline(always)]
pub fn empty() -> Vc<String> {
empty_string()
Expand All @@ -33,6 +34,7 @@ fn empty_string_vec() -> Vc<Vec<String>> {
}

impl Vc<Vec<String>> {
#[deprecated(note = "use Default::default() instead")]
#[inline(always)]
pub fn empty() -> Vc<Vec<String>> {
empty_string_vec()
Expand All @@ -47,17 +49,12 @@ fn option_string_none() -> Vc<Option<String>> {
}

impl Vc<Option<String>> {
#[deprecated(note = "use Default::default() instead")]
pub fn none() -> Self {
option_string_none()
}
}

impl Default for Vc<Option<String>> {
fn default() -> Self {
Self::none()
}
}

__turbo_tasks_internal_primitive!(bool);
__turbo_tasks_internal_primitive!(u8);
__turbo_tasks_internal_primitive!(u16);
Expand Down
11 changes: 2 additions & 9 deletions crates/turbo-tasks/src/unit.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
use crate::{ValueDefault, Vc};
use crate::Vc;

// TODO(alexkirsz) Should this be `#[turbo_tasks::function]` or is it okay to
// always return a new `Vc`?
#[deprecated(note = "use Default::default() instead")]
pub fn unit() -> Vc<()> {
Vc::cell(())
}

impl ValueDefault for () {
// TODO(alexkirsz) Should this be `#[turbo_tasks::function]` or is it
// preferrable to always return a new `Vc`?
fn value_default() -> Vc<Self> {
Vc::cell(())
}
}

0 comments on commit d4da097

Please sign in to comment.