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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use crate::{
database::{AstStorage, DocumentDatabase, DocumentStorage, HirStorage, InputStorage},
validation::ValidationStorage,
};
pub trait Upcast<T: ?Sized> {
fn upcast(&self) -> &T;
}
#[salsa::database(
DocumentStorage,
InputStorage,
AstStorage,
HirStorage,
ValidationStorage
)]
#[derive(Default)]
pub struct RootDatabase {
pub storage: salsa::Storage<RootDatabase>,
}
impl salsa::Database for RootDatabase {}
impl salsa::ParallelDatabase for RootDatabase {
fn snapshot(&self) -> salsa::Snapshot<RootDatabase> {
salsa::Snapshot::new(RootDatabase {
storage: self.storage.snapshot(),
})
}
}
impl Upcast<dyn DocumentDatabase> for RootDatabase {
fn upcast(&self) -> &(dyn DocumentDatabase + 'static) {
self
}
}