aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/attr.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/attr.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/attr.rs')
-rw-r--r--crates/ra_hir_def/src/attr.rs14
1 files changed, 6 insertions, 8 deletions
diff --git a/crates/ra_hir_def/src/attr.rs b/crates/ra_hir_def/src/attr.rs
index 9efa4970c..71a18f5e1 100644
--- a/crates/ra_hir_def/src/attr.rs
+++ b/crates/ra_hir_def/src/attr.rs
@@ -32,7 +32,7 @@ impl ops::Deref for Attrs {
32} 32}
33 33
34impl Attrs { 34impl Attrs {
35 pub(crate) fn attrs_query(db: &impl DefDatabase, def: AttrDefId) -> Attrs { 35 pub(crate) fn attrs_query(db: &dyn DefDatabase, def: AttrDefId) -> Attrs {
36 match def { 36 match def {
37 AttrDefId::ModuleId(module) => { 37 AttrDefId::ModuleId(module) => {
38 let def_map = db.crate_def_map(module.krate); 38 let def_map = db.crate_def_map(module.krate);
@@ -71,8 +71,8 @@ impl Attrs {
71 } 71 }
72 } 72 }
73 73
74 fn from_attrs_owner(db: &impl DefDatabase, owner: InFile<&dyn AttrsOwner>) -> Attrs { 74 fn from_attrs_owner(db: &dyn DefDatabase, owner: InFile<&dyn AttrsOwner>) -> Attrs {
75 let hygiene = Hygiene::new(db, owner.file_id); 75 let hygiene = Hygiene::new(db.upcast(), owner.file_id);
76 Attrs::new(owner.value, &hygiene) 76 Attrs::new(owner.value, &hygiene)
77 } 77 }
78 78
@@ -155,20 +155,18 @@ impl<'a> AttrQuery<'a> {
155 } 155 }
156} 156}
157 157
158fn attrs_from_ast<D, N>(src: AstId<N>, db: &D) -> Attrs 158fn attrs_from_ast<N>(src: AstId<N>, db: &dyn DefDatabase) -> Attrs
159where 159where
160 N: ast::AttrsOwner, 160 N: ast::AttrsOwner,
161 D: DefDatabase,
162{ 161{
163 let src = InFile::new(src.file_id, src.to_node(db)); 162 let src = InFile::new(src.file_id, src.to_node(db.upcast()));
164 Attrs::from_attrs_owner(db, src.as_ref().map(|it| it as &dyn AttrsOwner)) 163 Attrs::from_attrs_owner(db, src.as_ref().map(|it| it as &dyn AttrsOwner))
165} 164}
166 165
167fn attrs_from_loc<T, D>(node: T, db: &D) -> Attrs 166fn attrs_from_loc<T>(node: T, db: &dyn DefDatabase) -> Attrs
168where 167where
169 T: HasSource, 168 T: HasSource,
170 T::Value: ast::AttrsOwner, 169 T::Value: ast::AttrsOwner,
171 D: DefDatabase,
172{ 170{
173 let src = node.source(db); 171 let src = node.source(db);
174 Attrs::from_attrs_owner(db, src.as_ref().map(|it| it as &dyn AttrsOwner)) 172 Attrs::from_attrs_owner(db, src.as_ref().map(|it| it as &dyn AttrsOwner))