mirror of
https://github.com/salsa-rs/salsa.git
synced 2024-10-23 12:49:57 +00:00
remove GroupKey associated type
This commit is contained in:
parent
1a07944efe
commit
64f3eb96a1
4 changed files with 3 additions and 55 deletions
|
@ -180,11 +180,6 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream
|
|||
}
|
||||
}
|
||||
|
||||
let group_key = Ident::new(
|
||||
&format!("{}GroupKey__", trait_name.to_string()),
|
||||
Span::call_site(),
|
||||
);
|
||||
|
||||
let group_storage = Ident::new(
|
||||
&format!("{}GroupStorage__", trait_name.to_string()),
|
||||
Span::call_site(),
|
||||
|
@ -192,7 +187,6 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream
|
|||
|
||||
let mut query_fn_declarations = proc_macro2::TokenStream::new();
|
||||
let mut query_fn_definitions = proc_macro2::TokenStream::new();
|
||||
let mut query_descriptor_variants = proc_macro2::TokenStream::new();
|
||||
let mut storage_fields = proc_macro2::TokenStream::new();
|
||||
let mut queries_with_storage = vec![];
|
||||
for query in &queries {
|
||||
|
@ -283,11 +277,6 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream
|
|||
});
|
||||
}
|
||||
|
||||
// A variant for the group descriptor below
|
||||
query_descriptor_variants.extend(quote! {
|
||||
#fn_name((#(#keys),*)),
|
||||
});
|
||||
|
||||
// A field for the storage struct
|
||||
//
|
||||
// FIXME(#120): the pub should not be necessary once we complete the transition
|
||||
|
@ -319,7 +308,6 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream
|
|||
DB__: salsa::Database,
|
||||
{
|
||||
type GroupStorage = #group_storage<DB__>;
|
||||
type GroupKey = #group_key;
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -391,7 +379,6 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream
|
|||
type Storage = #storage;
|
||||
type Group = #group_struct;
|
||||
type GroupStorage = #group_storage<#db>;
|
||||
type GroupKey = #group_key;
|
||||
|
||||
const QUERY_INDEX: u16 = #query_index;
|
||||
|
||||
|
@ -402,10 +389,6 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream
|
|||
) -> &std::sync::Arc<Self::Storage> {
|
||||
&group_storage.#fn_name
|
||||
}
|
||||
|
||||
fn group_key(key: Self::Key) -> Self::GroupKey {
|
||||
#group_key::#fn_name(key)
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -455,15 +438,6 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream
|
|||
}
|
||||
}
|
||||
|
||||
// Emit query group descriptor
|
||||
output.extend(quote! {
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
#[allow(non_camel_case_types)]
|
||||
#trait_vis enum #group_key {
|
||||
#query_descriptor_variants
|
||||
}
|
||||
});
|
||||
|
||||
let mut fmt_ops = proc_macro2::TokenStream::new();
|
||||
for (Query { fn_name, .. }, query_index) in non_transparent_queries().zip(0_u16..) {
|
||||
fmt_ops.extend(quote! {
|
||||
|
|
|
@ -36,14 +36,7 @@ where
|
|||
Q: Query<DB>,
|
||||
Q::Key: InternKey,
|
||||
Q::Value: Eq + Hash,
|
||||
IQ: Query<
|
||||
DB,
|
||||
Key = Q::Value,
|
||||
Value = Q::Key,
|
||||
Group = Q::Group,
|
||||
GroupStorage = Q::GroupStorage,
|
||||
GroupKey = Q::GroupKey,
|
||||
>,
|
||||
IQ: Query<DB, Key = Q::Value, Value = Q::Key, Group = Q::Group, GroupStorage = Q::GroupStorage>,
|
||||
DB: Database,
|
||||
{
|
||||
phantom: std::marker::PhantomData<(Q::Key, IQ)>,
|
||||
|
@ -419,7 +412,6 @@ where
|
|||
Storage = InternedStorage<DB, IQ>,
|
||||
Group = Q::Group,
|
||||
GroupStorage = Q::GroupStorage,
|
||||
GroupKey = Q::GroupKey,
|
||||
>,
|
||||
DB: Database + HasQueryGroup<Q::Group>,
|
||||
{
|
||||
|
@ -487,14 +479,7 @@ where
|
|||
Q: Query<DB>,
|
||||
Q::Key: InternKey,
|
||||
Q::Value: Eq + Hash,
|
||||
IQ: Query<
|
||||
DB,
|
||||
Key = Q::Value,
|
||||
Value = Q::Key,
|
||||
Group = Q::Group,
|
||||
GroupStorage = Q::GroupStorage,
|
||||
GroupKey = Q::GroupKey,
|
||||
>,
|
||||
IQ: Query<DB, Key = Q::Value, Value = Q::Key, Group = Q::Group, GroupStorage = Q::GroupStorage>,
|
||||
DB: Database,
|
||||
{
|
||||
fn sweep(&self, _db: &DB, _strategy: SweepStrategy) {}
|
||||
|
|
12
src/lib.rs
12
src/lib.rs
|
@ -470,18 +470,11 @@ pub trait Query<DB: Database>: Debug + Default + Sized + 'static {
|
|||
type Storage: plumbing::QueryStorageOps<DB, Self>;
|
||||
|
||||
/// Associate query group struct.
|
||||
type Group: plumbing::QueryGroup<
|
||||
DB,
|
||||
GroupStorage = Self::GroupStorage,
|
||||
GroupKey = Self::GroupKey,
|
||||
>;
|
||||
type Group: plumbing::QueryGroup<DB, GroupStorage = Self::GroupStorage>;
|
||||
|
||||
/// Generated struct that contains storage for all queries in a group.
|
||||
type GroupStorage;
|
||||
|
||||
/// Type that identifies a particular query within the group + its key.
|
||||
type GroupKey;
|
||||
|
||||
/// A unique index identifying this query within the group.
|
||||
const QUERY_INDEX: u16;
|
||||
|
||||
|
@ -490,9 +483,6 @@ pub trait Query<DB: Database>: Debug + Default + Sized + 'static {
|
|||
|
||||
/// Extact storage for this query from the storage for its group.
|
||||
fn query_storage(group_storage: &Self::GroupStorage) -> &Arc<Self::Storage>;
|
||||
|
||||
/// Create group key for this query.
|
||||
fn group_key(key: Self::Key) -> Self::GroupKey;
|
||||
}
|
||||
|
||||
/// Return value from [the `query` method] on `Database`.
|
||||
|
|
|
@ -110,7 +110,6 @@ where
|
|||
|
||||
pub trait QueryGroup<DB: Database> {
|
||||
type GroupStorage;
|
||||
type GroupKey;
|
||||
}
|
||||
|
||||
/// Trait implemented by a database for each group that it supports.
|
||||
|
|
Loading…
Reference in a new issue