remove GroupKey associated type

This commit is contained in:
Niko Matsakis 2020-07-01 10:06:45 +00:00
parent 1a07944efe
commit 64f3eb96a1
4 changed files with 3 additions and 55 deletions

View file

@ -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! {

View file

@ -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) {}

View file

@ -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`.

View file

@ -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.