aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_db/src/lib.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_ide_db/src/lib.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_ide_db/src/lib.rs')
-rw-r--r--crates/ra_ide_db/src/lib.rs15
1 files changed, 14 insertions, 1 deletions
diff --git a/crates/ra_ide_db/src/lib.rs b/crates/ra_ide_db/src/lib.rs
index fc1b19def..4faeefa8d 100644
--- a/crates/ra_ide_db/src/lib.rs
+++ b/crates/ra_ide_db/src/lib.rs
@@ -14,10 +14,11 @@ mod wasm_shims;
14 14
15use std::sync::Arc; 15use std::sync::Arc;
16 16
17use hir::db::{AstDatabase, DefDatabase};
17use ra_db::{ 18use ra_db::{
18 salsa::{self, Database, Durability}, 19 salsa::{self, Database, Durability},
19 Canceled, CheckCanceled, CrateId, FileId, FileLoader, FileLoaderDelegate, RelativePath, 20 Canceled, CheckCanceled, CrateId, FileId, FileLoader, FileLoaderDelegate, RelativePath,
20 SourceDatabase, SourceRootId, 21 SourceDatabase, SourceRootId, Upcast,
21}; 22};
22use rustc_hash::FxHashMap; 23use rustc_hash::FxHashMap;
23 24
@@ -41,6 +42,18 @@ pub struct RootDatabase {
41 pub last_gc_check: crate::wasm_shims::Instant, 42 pub last_gc_check: crate::wasm_shims::Instant,
42} 43}
43 44
45impl Upcast<dyn AstDatabase> for RootDatabase {
46 fn upcast(&self) -> &(dyn AstDatabase + 'static) {
47 &*self
48 }
49}
50
51impl Upcast<dyn DefDatabase> for RootDatabase {
52 fn upcast(&self) -> &(dyn DefDatabase + 'static) {
53 &*self
54 }
55}
56
44impl FileLoader for RootDatabase { 57impl FileLoader for RootDatabase {
45 fn file_text(&self, file_id: FileId) -> Arc<String> { 58 fn file_text(&self, file_id: FileId) -> Arc<String> {
46 FileLoaderDelegate(self).file_text(file_id) 59 FileLoaderDelegate(self).file_text(file_id)