mirror of
https://github.com/salsa-rs/salsa.git
synced 2024-12-01 04:18:30 +00:00
remove the need to manually specify the QueryDescriptor
The macro can handle it now.
This commit is contained in:
parent
2e40e9d1e5
commit
5bee46108d
3 changed files with 10 additions and 8 deletions
|
@ -37,8 +37,6 @@ impl CompilerQueryContext for QueryContextImpl {
|
|||
// permit behavior refinement.
|
||||
|
||||
impl salsa::QueryContext for QueryContextImpl {
|
||||
type QueryDescriptor = salsa::dyn_descriptor::DynDescriptor;
|
||||
|
||||
fn salsa_runtime(&self) -> &salsa::runtime::Runtime<QueryContextImpl> {
|
||||
&self.runtime
|
||||
}
|
||||
|
|
|
@ -26,8 +26,6 @@ impl queries::CounterContext for QueryContextImpl {
|
|||
}
|
||||
|
||||
impl salsa::QueryContext for QueryContextImpl {
|
||||
type QueryDescriptor = salsa::dyn_descriptor::DynDescriptor;
|
||||
|
||||
fn salsa_runtime(&self) -> &salsa::runtime::Runtime<QueryContextImpl> {
|
||||
&self.runtime
|
||||
}
|
||||
|
|
14
src/lib.rs
14
src/lib.rs
|
@ -26,7 +26,12 @@ pub mod transparent;
|
|||
|
||||
pub use self::runtime::Runtime;
|
||||
|
||||
pub trait QueryContext: Sized {
|
||||
pub trait QueryContext: Sized + HasQueryContextDescriptor {
|
||||
/// Gives access to the underlying salsa runtime.
|
||||
fn salsa_runtime(&self) -> &runtime::Runtime<Self>;
|
||||
}
|
||||
|
||||
pub trait HasQueryContextDescriptor {
|
||||
/// A "query descriptor" packages up all the possible queries and a key.
|
||||
/// It is used to store information about (e.g.) the stack.
|
||||
///
|
||||
|
@ -34,9 +39,6 @@ pub trait QueryContext: Sized {
|
|||
/// works for a fixed set of queries, but a boxed trait object is good
|
||||
/// for a more open-ended option.
|
||||
type QueryDescriptor: Debug + Eq;
|
||||
|
||||
/// Gives access to the underlying salsa runtime.
|
||||
fn salsa_runtime(&self) -> &runtime::Runtime<Self>;
|
||||
}
|
||||
|
||||
pub trait Query<QC: QueryContext>: Debug + Default + Sized + 'static {
|
||||
|
@ -326,6 +328,10 @@ macro_rules! query_context_storage {
|
|||
)*
|
||||
}
|
||||
|
||||
impl $crate::HasQueryContextDescriptor for $QueryContext {
|
||||
type QueryDescriptor = $crate::dyn_descriptor::DynDescriptor;
|
||||
}
|
||||
|
||||
$(
|
||||
impl $TraitName for $QueryContext {
|
||||
$(
|
||||
|
|
Loading…
Reference in a new issue