remove the need to manually specify the QueryDescriptor

The macro can handle it now.
This commit is contained in:
Niko Matsakis 2018-09-29 05:44:34 -04:00
parent 2e40e9d1e5
commit 5bee46108d
3 changed files with 10 additions and 8 deletions

View file

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

View file

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

View file

@ -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 {
$(