make query_group macro procedural

Switch to a procedural implementation of the `query_group!` macro,
residing in the `components/salsa_macros` subcrate.

Allow the user to override the invoked function via `salsa::invoke(...)`
and the name of the generated query type via `salsa::query_type(...)`.

In all tests, replace the `salsa::query_group! { ... }` invocations with
the new attribute-style `#[salsa::query_group]` macro, and change them
to the new naming scheme for query types (`...Query`).

Update README, examples, and documentation.
This commit is contained in:
Fabian Schuiki 2019-01-12 11:11:59 +01:00
parent cd454e986e
commit 93c30a953d
35 changed files with 768 additions and 782 deletions

View file

@ -1,4 +1,4 @@
use crate::setup::{Input, ParDatabase, ParDatabaseImpl};
use crate::setup::{InputQuery, ParDatabase, ParDatabaseImpl};
use salsa::{Database, ParallelDatabase};
/// Test two `sum` queries (on distinct keys) executing in different
@ -7,12 +7,12 @@ use salsa::{Database, ParallelDatabase};
fn in_par_two_independent_queries() {
let mut db = ParDatabaseImpl::default();
db.query_mut(Input).set('a', 100);
db.query_mut(Input).set('b', 010);
db.query_mut(Input).set('c', 001);
db.query_mut(Input).set('d', 200);
db.query_mut(Input).set('e', 020);
db.query_mut(Input).set('f', 002);
db.query_mut(InputQuery).set('a', 100);
db.query_mut(InputQuery).set('b', 010);
db.query_mut(InputQuery).set('c', 001);
db.query_mut(InputQuery).set('d', 200);
db.query_mut(InputQuery).set('e', 020);
db.query_mut(InputQuery).set('f', 002);
let thread1 = std::thread::spawn({
let db = db.snapshot();