diff --git a/components/salsa-macros/src/database_storage.rs b/components/salsa-macros/src/database_storage.rs index 9e6c69a7..c97921d5 100644 --- a/components/salsa-macros/src/database_storage.rs +++ b/components/salsa-macros/src/database_storage.rs @@ -80,7 +80,7 @@ pub(crate) fn database_storage(input: TokenStream) -> TokenStream { // rewrite the last identifier (`MyGroup`, above) to // (e.g.) `MyGroupGroupStorage`. descriptor_impls.extend(quote! { - impl ::salsa::plumbing::FromQueryGroupDescriptor<#group_descriptor> for #database_name { + impl ::salsa::plumbing::GetDatabaseDescriptor<#group_descriptor> for #database_name { fn from(descriptor: #group_descriptor) -> __SalsaQueryDescriptor { __SalsaQueryDescriptor { kind: __SalsaQueryDescriptorKind::#group_name(descriptor), @@ -226,7 +226,7 @@ pub(crate) fn database_storage(input: TokenStream) -> TokenStream { db: &Self, key: <#query_type as ::salsa::Query>::Key, ) -> ::QueryDescriptor { - >::from(#group_descriptor::#query_name(key)) + >::from(#group_descriptor::#query_name(key)) } } }); diff --git a/components/salsa-macros/src/query_group.rs b/components/salsa-macros/src/query_group.rs index 4e745ea9..b7417778 100644 --- a/components/salsa-macros/src/query_group.rs +++ b/components/salsa-macros/src/query_group.rs @@ -206,7 +206,7 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream where T: #(salsa::plumbing::GetQueryTable<#qts> +)* #bounds, T: ::salsa::plumbing::GetQueryGroupStorage<#group_storage>, - T: ::salsa::plumbing::FromQueryGroupDescriptor<#group_descriptor>, + T: ::salsa::plumbing::GetDatabaseDescriptor<#group_descriptor>, { #query_fn_definitions } diff --git a/src/plumbing.rs b/src/plumbing.rs index 0ac28ea7..de85f9b8 100644 --- a/src/plumbing.rs +++ b/src/plumbing.rs @@ -81,11 +81,20 @@ pub trait GetQueryTable>: Database { fn descriptor(db: &Self, key: Q::Key) -> Self::QueryDescriptor; } +/// Access the "group storage" with type `S` from the database. +/// +/// This basically moves from the full context of the database to the context +/// of one query group. pub trait GetQueryGroupStorage: Database { fn from(db: &Self) -> &S; } -pub trait FromQueryGroupDescriptor: Database { +/// Given a group descriptor of type `D`, convert it to a full +/// database query descriptor. +/// +/// This basically moves a descriptor from the context of the query +/// group into the full context of the database. +pub trait GetDatabaseDescriptor: Database { fn from(descriptor: D) -> Self::QueryDescriptor; }