aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/test_db.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-03-13 15:05:46 +0000
committerAleksey Kladov <[email protected]>2020-03-16 16:42:30 +0000
commit9faea2364dee4fbc9391ad233c570b70256ef002 (patch)
tree160af959553ce57fdfcbc0a6c79bafcc3611aeea /crates/ra_hir_def/src/test_db.rs
parent648df02953a6ebf87a5876668eceba208687e8a7 (diff)
Use `dyn Trait` for working with databse
It improves compile time in `--release` mode quite a bit, it doesn't really slow things down and, conceptually, it seems closer to what we want the physical architecture to look like (we don't want to monomorphise EVERYTHING in a single leaf crate).
Diffstat (limited to 'crates/ra_hir_def/src/test_db.rs')
-rw-r--r--crates/ra_hir_def/src/test_db.rs18
1 files changed, 17 insertions, 1 deletions
diff --git a/crates/ra_hir_def/src/test_db.rs b/crates/ra_hir_def/src/test_db.rs
index 0756916a8..eb83dee79 100644
--- a/crates/ra_hir_def/src/test_db.rs
+++ b/crates/ra_hir_def/src/test_db.rs
@@ -5,8 +5,12 @@ use std::{
5 sync::{Arc, Mutex}, 5 sync::{Arc, Mutex},
6}; 6};
7 7
8use hir_expand::db::AstDatabase;
9use ra_db::{
10 salsa, CrateId, ExternSourceId, FileId, FileLoader, FileLoaderDelegate, RelativePath, Upcast,
11};
12
8use crate::db::DefDatabase; 13use crate::db::DefDatabase;
9use ra_db::{salsa, CrateId, ExternSourceId, FileId, FileLoader, FileLoaderDelegate, RelativePath};
10 14
11#[salsa::database( 15#[salsa::database(
12 ra_db::SourceDatabaseExtStorage, 16 ra_db::SourceDatabaseExtStorage,
@@ -21,6 +25,18 @@ pub struct TestDB {
21 events: Mutex<Option<Vec<salsa::Event<TestDB>>>>, 25 events: Mutex<Option<Vec<salsa::Event<TestDB>>>>,
22} 26}
23 27
28impl Upcast<dyn AstDatabase> for TestDB {
29 fn upcast(&self) -> &(dyn AstDatabase + 'static) {
30 &*self
31 }
32}
33
34impl Upcast<dyn DefDatabase> for TestDB {
35 fn upcast(&self) -> &(dyn DefDatabase + 'static) {
36 &*self
37 }
38}
39
24impl salsa::Database for TestDB { 40impl salsa::Database for TestDB {
25 fn salsa_runtime(&self) -> &salsa::Runtime<Self> { 41 fn salsa_runtime(&self) -> &salsa::Runtime<Self> {
26 &self.runtime 42 &self.runtime