From 9faea2364dee4fbc9391ad233c570b70256ef002 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 13 Mar 2020 16:05:46 +0100 Subject: 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). --- crates/ra_hir_def/src/db.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'crates/ra_hir_def/src/db.rs') diff --git a/crates/ra_hir_def/src/db.rs b/crates/ra_hir_def/src/db.rs index dcd377aae..7f8c1ea21 100644 --- a/crates/ra_hir_def/src/db.rs +++ b/crates/ra_hir_def/src/db.rs @@ -2,7 +2,7 @@ use std::sync::Arc; use hir_expand::{db::AstDatabase, HirFileId}; -use ra_db::{salsa, CrateId, SourceDatabase}; +use ra_db::{salsa, CrateId, SourceDatabase, Upcast}; use ra_prof::profile; use ra_syntax::SmolStr; @@ -43,7 +43,7 @@ pub trait InternDatabase: SourceDatabase { } #[salsa::query_group(DefDatabaseStorage)] -pub trait DefDatabase: InternDatabase + AstDatabase { +pub trait DefDatabase: InternDatabase + AstDatabase + Upcast { #[salsa::invoke(RawItems::raw_items_query)] fn raw_items(&self, file_id: HirFileId) -> Arc; @@ -109,6 +109,12 @@ pub trait DefDatabase: InternDatabase + AstDatabase { fn documentation(&self, def: AttrDefId) -> Option; } +// impl Upcast for T { +// fn upcast(&self) -> &dyn AstDatabase { +// &*self +// } +// } + fn crate_def_map_wait(db: &impl DefDatabase, krate: CrateId) -> Arc { let _p = profile("crate_def_map:wait"); db.crate_def_map_query(krate) -- cgit v1.2.3