mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-02-10 14:14:13 +00:00
do not generate in_db_mut
when it is inappropriate
This commit is contained in:
parent
d2e9f64bda
commit
fd036a4f15
1 changed files with 20 additions and 0 deletions
|
@ -364,7 +364,9 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream
|
||||||
output.extend(quote! {
|
output.extend(quote! {
|
||||||
#[derive(Default, Debug)]
|
#[derive(Default, Debug)]
|
||||||
#trait_vis struct #qt;
|
#trait_vis struct #qt;
|
||||||
|
});
|
||||||
|
|
||||||
|
output.extend(quote! {
|
||||||
impl #qt {
|
impl #qt {
|
||||||
/// Get access to extra methods pertaining to this query. For
|
/// Get access to extra methods pertaining to this query. For
|
||||||
/// example, you can use this to run the GC (`sweep`) across a
|
/// example, you can use this to run the GC (`sweep`) across a
|
||||||
|
@ -375,7 +377,12 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream
|
||||||
{
|
{
|
||||||
salsa::plumbing::get_query_table::<#qt>(db)
|
salsa::plumbing::get_query_table::<#qt>(db)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if query.storage.supports_mut() {}
|
||||||
|
output.extend(quote! {
|
||||||
|
impl #qt {
|
||||||
/// Like `in_db`, but gives access to methods for setting the
|
/// Like `in_db`, but gives access to methods for setting the
|
||||||
/// value of an input. Not applicable to derived queries.
|
/// value of an input. Not applicable to derived queries.
|
||||||
///
|
///
|
||||||
|
@ -651,6 +658,7 @@ enum QueryStorage {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl QueryStorage {
|
impl QueryStorage {
|
||||||
|
/// Do we need a `QueryFunction` impl for this type of query?
|
||||||
fn needs_query_function(&self) -> bool {
|
fn needs_query_function(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
QueryStorage::Input
|
QueryStorage::Input
|
||||||
|
@ -660,4 +668,16 @@ impl QueryStorage {
|
||||||
QueryStorage::Memoized | QueryStorage::Dependencies => true,
|
QueryStorage::Memoized | QueryStorage::Dependencies => true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Does this type of query support `&mut` operations?
|
||||||
|
fn supports_mut(&self) -> bool {
|
||||||
|
match self {
|
||||||
|
QueryStorage::Input => true,
|
||||||
|
QueryStorage::Interned
|
||||||
|
| QueryStorage::InternedLookup { .. }
|
||||||
|
| QueryStorage::Transparent
|
||||||
|
| QueryStorage::Memoized
|
||||||
|
| QueryStorage::Dependencies => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue