about summary refs log tree commit diff
path: root/src/tools/rust-analyzer/crates/query-group-macro/tests/multiple_dbs.rs
blob: f36e7fdbebf7fff423b4784e3f59ed7a1381c67e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
use query_group_macro::query_group;

#[query_group]
pub trait DatabaseOne: salsa::Database {
    #[salsa::input]
    fn input_string(&self) -> String;

    // unadorned query
    #[salsa::invoke_interned(length)]
    fn length(&self, key: ()) -> usize;
}

#[query_group]
pub trait DatabaseTwo: DatabaseOne {
    #[salsa::invoke_interned(second_length)]
    fn second_length(&self, key: ()) -> usize;
}

fn length(db: &dyn DatabaseOne, _key: ()) -> usize {
    db.input_string().len()
}

fn second_length(db: &dyn DatabaseTwo, _key: ()) -> usize {
    db.input_string().len()
}