aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_expand
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_expand
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_expand')
-rw-r--r--crates/ra_hir_expand/src/db.rs2
-rw-r--r--crates/ra_hir_expand/src/eager.rs6
-rw-r--r--crates/ra_hir_expand/src/hygiene.rs2
-rw-r--r--crates/ra_hir_expand/src/lib.rs6
4 files changed, 8 insertions, 8 deletions
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 {
77/// token. The `token_to_map` mapped down into the expansion, with the mapped 77/// token. The `token_to_map` mapped down into the expansion, with the mapped
78/// token returned. 78/// token returned.
79pub fn expand_hypothetical( 79pub fn expand_hypothetical(
80 db: &impl AstDatabase, 80 db: &dyn AstDatabase,
81 actual_macro_call: MacroCallId, 81 actual_macro_call: MacroCallId,
82 hypothetical_args: &ra_syntax::ast::TokenTree, 82 hypothetical_args: &ra_syntax::ast::TokenTree,
83 token_to_map: ra_syntax::SyntaxToken, 83 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};
30use std::{collections::HashMap, sync::Arc}; 30use std::{collections::HashMap, sync::Arc};
31 31
32pub fn expand_eager_macro( 32pub fn expand_eager_macro(
33 db: &impl AstDatabase, 33 db: &dyn AstDatabase,
34 macro_call: InFile<ast::MacroCall>, 34 macro_call: InFile<ast::MacroCall>,
35 def: MacroDefId, 35 def: MacroDefId,
36 resolver: &dyn Fn(ast::Path) -> Option<MacroDefId>, 36 resolver: &dyn Fn(ast::Path) -> Option<MacroDefId>,
@@ -78,7 +78,7 @@ fn to_subtree(node: &SyntaxNode) -> Option<tt::Subtree> {
78} 78}
79 79
80fn lazy_expand( 80fn lazy_expand(
81 db: &impl AstDatabase, 81 db: &dyn AstDatabase,
82 def: &MacroDefId, 82 def: &MacroDefId,
83 macro_call: InFile<ast::MacroCall>, 83 macro_call: InFile<ast::MacroCall>,
84) -> Option<InFile<SyntaxNode>> { 84) -> Option<InFile<SyntaxNode>> {
@@ -91,7 +91,7 @@ fn lazy_expand(
91} 91}
92 92
93fn eager_macro_recur( 93fn eager_macro_recur(
94 db: &impl AstDatabase, 94 db: &dyn AstDatabase,
95 curr: InFile<SyntaxNode>, 95 curr: InFile<SyntaxNode>,
96 macro_resolver: &dyn Fn(ast::Path) -> Option<MacroDefId>, 96 macro_resolver: &dyn Fn(ast::Path) -> Option<MacroDefId>,
97) -> Option<SyntaxNode> { 97) -> Option<SyntaxNode> {
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 {
19} 19}
20 20
21impl Hygiene { 21impl Hygiene {
22 pub fn new(db: &impl AstDatabase, file_id: HirFileId) -> Hygiene { 22 pub fn new(db: &dyn AstDatabase, file_id: HirFileId) -> Hygiene {
23 let def_crate = match file_id.0 { 23 let def_crate = match file_id.0 {
24 HirFileIdRepr::FileId(_) => None, 24 HirFileIdRepr::FileId(_) => None,
25 HirFileIdRepr::MacroFile(macro_file) => match macro_file.macro_call_id { 25 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<T> InFile<T> {
366 pub fn as_ref(&self) -> InFile<&T> { 366 pub fn as_ref(&self) -> InFile<&T> {
367 self.with_value(&self.value) 367 self.with_value(&self.value)
368 } 368 }
369 pub fn file_syntax(&self, db: &impl db::AstDatabase) -> SyntaxNode { 369 pub fn file_syntax(&self, db: &dyn db::AstDatabase) -> SyntaxNode {
370 db.parse_or_expand(self.file_id).expect("source created from invalid file") 370 db.parse_or_expand(self.file_id).expect("source created from invalid file")
371 } 371 }
372} 372}
@@ -387,7 +387,7 @@ impl<T> InFile<Option<T>> {
387impl InFile<SyntaxNode> { 387impl InFile<SyntaxNode> {
388 pub fn ancestors_with_macros( 388 pub fn ancestors_with_macros(
389 self, 389 self,
390 db: &impl crate::db::AstDatabase, 390 db: &dyn db::AstDatabase,
391 ) -> impl Iterator<Item = InFile<SyntaxNode>> + '_ { 391 ) -> impl Iterator<Item = InFile<SyntaxNode>> + '_ {
392 std::iter::successors(Some(self), move |node| match node.value.parent() { 392 std::iter::successors(Some(self), move |node| match node.value.parent() {
393 Some(parent) => Some(node.with_value(parent)), 393 Some(parent) => Some(node.with_value(parent)),
@@ -402,7 +402,7 @@ impl InFile<SyntaxNode> {
402impl InFile<SyntaxToken> { 402impl InFile<SyntaxToken> {
403 pub fn ancestors_with_macros( 403 pub fn ancestors_with_macros(
404 self, 404 self,
405 db: &impl crate::db::AstDatabase, 405 db: &dyn db::AstDatabase,
406 ) -> impl Iterator<Item = InFile<SyntaxNode>> + '_ { 406 ) -> impl Iterator<Item = InFile<SyntaxNode>> + '_ {
407 self.map(|it| it.parent()).ancestors_with_macros(db) 407 self.map(|it| it.parent()).ancestors_with_macros(db)
408 } 408 }