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_expand/src/db.rs | 2 +- crates/ra_hir_expand/src/eager.rs | 6 +++--- crates/ra_hir_expand/src/hygiene.rs | 2 +- crates/ra_hir_expand/src/lib.rs | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) (limited to 'crates/ra_hir_expand/src') diff --git a/crates/ra_hir_expand/src/db.rs b/crates/ra_hir_expand/src/db.rs index 29dde3d80..c3e1c68b7 100644 --- a/crates/ra_hir_expand/src/db.rs +++ b/crates/ra_hir_expand/src/db.rs @@ -77,7 +77,7 @@ pub trait AstDatabase: SourceDatabase { /// token. The `token_to_map` mapped down into the expansion, with the mapped /// token returned. pub fn expand_hypothetical( - db: &impl AstDatabase, + db: &dyn AstDatabase, actual_macro_call: MacroCallId, hypothetical_args: &ra_syntax::ast::TokenTree, token_to_map: ra_syntax::SyntaxToken, diff --git a/crates/ra_hir_expand/src/eager.rs b/crates/ra_hir_expand/src/eager.rs index 2e6dd3dd8..4cbce4df5 100644 --- a/crates/ra_hir_expand/src/eager.rs +++ b/crates/ra_hir_expand/src/eager.rs @@ -30,7 +30,7 @@ use ra_syntax::{algo::replace_descendants, SyntaxElement, SyntaxNode}; use std::{collections::HashMap, sync::Arc}; pub fn expand_eager_macro( - db: &impl AstDatabase, + db: &dyn AstDatabase, macro_call: InFile, def: MacroDefId, resolver: &dyn Fn(ast::Path) -> Option, @@ -78,7 +78,7 @@ fn to_subtree(node: &SyntaxNode) -> Option { } fn lazy_expand( - db: &impl AstDatabase, + db: &dyn AstDatabase, def: &MacroDefId, macro_call: InFile, ) -> Option> { @@ -91,7 +91,7 @@ fn lazy_expand( } fn eager_macro_recur( - db: &impl AstDatabase, + db: &dyn AstDatabase, curr: InFile, macro_resolver: &dyn Fn(ast::Path) -> Option, ) -> Option { diff --git a/crates/ra_hir_expand/src/hygiene.rs b/crates/ra_hir_expand/src/hygiene.rs index cb554ae4b..dfbac494f 100644 --- a/crates/ra_hir_expand/src/hygiene.rs +++ b/crates/ra_hir_expand/src/hygiene.rs @@ -19,7 +19,7 @@ pub struct Hygiene { } impl Hygiene { - pub fn new(db: &impl AstDatabase, file_id: HirFileId) -> Hygiene { + pub fn new(db: &dyn AstDatabase, file_id: HirFileId) -> Hygiene { let def_crate = match file_id.0 { HirFileIdRepr::FileId(_) => None, HirFileIdRepr::MacroFile(macro_file) => match macro_file.macro_call_id { diff --git a/crates/ra_hir_expand/src/lib.rs b/crates/ra_hir_expand/src/lib.rs index 7b72eb7a0..6b59ea4c9 100644 --- a/crates/ra_hir_expand/src/lib.rs +++ b/crates/ra_hir_expand/src/lib.rs @@ -366,7 +366,7 @@ impl InFile { pub fn as_ref(&self) -> InFile<&T> { self.with_value(&self.value) } - pub fn file_syntax(&self, db: &impl db::AstDatabase) -> SyntaxNode { + pub fn file_syntax(&self, db: &dyn db::AstDatabase) -> SyntaxNode { db.parse_or_expand(self.file_id).expect("source created from invalid file") } } @@ -387,7 +387,7 @@ impl InFile> { impl InFile { pub fn ancestors_with_macros( self, - db: &impl crate::db::AstDatabase, + db: &dyn db::AstDatabase, ) -> impl Iterator> + '_ { std::iter::successors(Some(self), move |node| match node.value.parent() { Some(parent) => Some(node.with_value(parent)), @@ -402,7 +402,7 @@ impl InFile { impl InFile { pub fn ancestors_with_macros( self, - db: &impl crate::db::AstDatabase, + db: &dyn db::AstDatabase, ) -> impl Iterator> + '_ { self.map(|it| it.parent()).ancestors_with_macros(db) } -- cgit v1.2.3