diff --git a/components/salsa-2022-macros/src/input.rs b/components/salsa-2022-macros/src/input.rs index 99e7a246..e1a815c4 100644 --- a/components/salsa-2022-macros/src/input.rs +++ b/components/salsa-2022-macros/src/input.rs @@ -17,16 +17,36 @@ pub(crate) fn input( } } -struct InputStruct(SalsaStruct); +struct InputStruct(SalsaStruct); impl std::ops::Deref for InputStruct { - type Target = SalsaStruct; + type Target = SalsaStruct; fn deref(&self) -> &Self::Target { &self.0 } } +impl crate::options::AllowedOptions for InputStruct { + const RETURN_REF: bool = false; + + const SPECIFY: bool = false; + + const NO_EQ: bool = false; + + const JAR: bool = true; + + const DATA: bool = true; + + const DB: bool = false; + + const RECOVERY_FN: bool = false; + + const LRU: bool = false; + + const CONSTRUCTOR_NAME: bool = true; +} + impl InputStruct { fn generate_input(&self) -> syn::Result { self.validate_input()?; diff --git a/components/salsa-2022-macros/src/interned.rs b/components/salsa-2022-macros/src/interned.rs index 47d75140..f3a4ab85 100644 --- a/components/salsa-2022-macros/src/interned.rs +++ b/components/salsa-2022-macros/src/interned.rs @@ -20,16 +20,36 @@ pub(crate) fn interned( } } -struct InternedStruct(SalsaStruct); +struct InternedStruct(SalsaStruct); impl std::ops::Deref for InternedStruct { - type Target = SalsaStruct; + type Target = SalsaStruct; fn deref(&self) -> &Self::Target { &self.0 } } +impl crate::options::AllowedOptions for InternedStruct { + const RETURN_REF: bool = false; + + const SPECIFY: bool = false; + + const NO_EQ: bool = false; + + const JAR: bool = true; + + const DATA: bool = true; + + const DB: bool = false; + + const RECOVERY_FN: bool = false; + + const LRU: bool = false; + + const CONSTRUCTOR_NAME: bool = true; +} + impl InternedStruct { fn generate_interned(&self) -> syn::Result { self.validate_interned()?; diff --git a/components/salsa-2022-macros/src/salsa_struct.rs b/components/salsa-2022-macros/src/salsa_struct.rs index d6884ca6..ec16042a 100644 --- a/components/salsa-2022-macros/src/salsa_struct.rs +++ b/components/salsa-2022-macros/src/salsa_struct.rs @@ -29,37 +29,20 @@ use heck::ToUpperCamelCase; use proc_macro2::{Ident, Literal, Span, TokenStream}; use syn::spanned::Spanned; -use crate::{configuration, options::Options}; +use crate::{ + configuration, + options::{AllowedOptions, Options}, +}; -pub(crate) struct SalsaStruct { - args: Options, +pub(crate) struct SalsaStruct { + args: Options, struct_item: syn::ItemStruct, fields: Vec, } -impl crate::options::AllowedOptions for SalsaStruct { - const RETURN_REF: bool = false; - - const SPECIFY: bool = false; - - const NO_EQ: bool = false; - - const JAR: bool = true; - - const DATA: bool = true; - - const DB: bool = false; - - const RECOVERY_FN: bool = false; - - const LRU: bool = false; - - const CONSTRUCTOR_NAME: bool = true; -} - const BANNED_FIELD_NAMES: &[&str] = &["from", "new"]; -impl SalsaStruct { +impl SalsaStruct { pub(crate) fn new( args: proc_macro::TokenStream, input: proc_macro::TokenStream, diff --git a/components/salsa-2022-macros/src/tracked_struct.rs b/components/salsa-2022-macros/src/tracked_struct.rs index 7bec3f54..dcc66c74 100644 --- a/components/salsa-2022-macros/src/tracked_struct.rs +++ b/components/salsa-2022-macros/src/tracked_struct.rs @@ -19,16 +19,36 @@ pub(crate) fn tracked( } } -struct TrackedStruct(SalsaStruct); +struct TrackedStruct(SalsaStruct); impl std::ops::Deref for TrackedStruct { - type Target = SalsaStruct; + type Target = SalsaStruct; fn deref(&self) -> &Self::Target { &self.0 } } +impl crate::options::AllowedOptions for TrackedStruct { + const RETURN_REF: bool = false; + + const SPECIFY: bool = false; + + const NO_EQ: bool = false; + + const JAR: bool = true; + + const DATA: bool = true; + + const DB: bool = false; + + const RECOVERY_FN: bool = false; + + const LRU: bool = false; + + const CONSTRUCTOR_NAME: bool = true; +} + impl TrackedStruct { fn generate_tracked(&self) -> syn::Result { self.validate_tracked()?;