Replace inputs' FunctionIngredients with InputFieldIngredients

This commit is contained in:
Mihail Mihov 2022-08-11 20:26:53 +03:00
parent da43bd2ba6
commit ec141aceba

View file

@ -35,7 +35,7 @@ impl InputStruct {
let id_struct = self.id_struct(); let id_struct = self.id_struct();
let inherent_impl = self.input_inherent_impl(); let inherent_impl = self.input_inherent_impl();
let ingredients_for_impl = self.input_ingredients(&config_structs); let ingredients_for_impl = self.input_ingredients();
let as_id_impl = self.as_id_impl(); let as_id_impl = self.as_id_impl();
let salsa_struct_in_db_impl = self.salsa_struct_in_db_impl(); let salsa_struct_in_db_impl = self.salsa_struct_in_db_impl();
@ -74,7 +74,7 @@ impl InputStruct {
{ {
let (__jar, __runtime) = <_ as salsa::storage::HasJar<#jar_ty>>::jar(__db); let (__jar, __runtime) = <_ as salsa::storage::HasJar<#jar_ty>>::jar(__db);
let __ingredients = <#jar_ty as salsa::storage::HasIngredientsFor< #ident >>::ingredient(__jar); let __ingredients = <#jar_ty as salsa::storage::HasIngredientsFor< #ident >>::ingredient(__jar);
__ingredients.#field_index.fetch(__db, self) __ingredients.#field_index.fetch(self)
} }
} }
} else { } else {
@ -83,7 +83,7 @@ impl InputStruct {
{ {
let (__jar, __runtime) = <_ as salsa::storage::HasJar<#jar_ty>>::jar(__db); let (__jar, __runtime) = <_ as salsa::storage::HasJar<#jar_ty>>::jar(__db);
let __ingredients = <#jar_ty as salsa::storage::HasIngredientsFor< #ident >>::ingredient(__jar); let __ingredients = <#jar_ty as salsa::storage::HasIngredientsFor< #ident >>::ingredient(__jar);
__ingredients.#field_index.fetch(__db, self).clone() __ingredients.#field_index.fetch(self).clone()
} }
} }
} }
@ -127,19 +127,19 @@ impl InputStruct {
/// ///
/// The entity's ingredients include both the main entity ingredient along with a /// The entity's ingredients include both the main entity ingredient along with a
/// function ingredient for each of the value fields. /// function ingredient for each of the value fields.
fn input_ingredients(&self, config_structs: &[syn::ItemStruct]) -> syn::ItemImpl { fn input_ingredients(&self) -> syn::ItemImpl {
let ident = self.id_ident(); let ident = self.id_ident();
let field_ty = self.all_field_tys();
let jar_ty = self.jar_ty(); let jar_ty = self.jar_ty();
let all_field_indices: Vec<Literal> = self.all_field_indices(); let all_field_indices: Vec<Literal> = self.all_field_indices();
let input_index: Literal = self.input_index(); let input_index: Literal = self.input_index();
let config_struct_names = config_structs.iter().map(|s| &s.ident);
parse_quote! { parse_quote! {
impl salsa::storage::IngredientsFor for #ident { impl salsa::storage::IngredientsFor for #ident {
type Jar = #jar_ty; type Jar = #jar_ty;
type Ingredients = ( type Ingredients = (
#( #(
salsa::function::FunctionIngredient<#config_struct_names>, salsa::input_field::InputFieldIngredient<#ident, #field_ty>,
)* )*
salsa::input::InputIngredient<#ident>, salsa::input::InputIngredient<#ident>,
); );
@ -160,7 +160,7 @@ impl InputStruct {
&ingredients.#all_field_indices &ingredients.#all_field_indices
}, },
); );
salsa::function::FunctionIngredient::new(index) salsa::input_field::InputFieldIngredient::new(index)
}, },
)* )*
{ {