aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/attr.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-03-16 16:42:58 +0000
committerGitHub <[email protected]>2020-03-16 16:42:58 +0000
commitadcc89137d3feea8f19fad461bbde6f4bce048e5 (patch)
tree160af959553ce57fdfcbc0a6c79bafcc3611aeea /crates/ra_hir_def/src/attr.rs
parent648df02953a6ebf87a5876668eceba208687e8a7 (diff)
parent9faea2364dee4fbc9391ad233c570b70256ef002 (diff)
Merge #3584
3584: Switch to dynamic dispatch r=matklad a=matklad Benches are in https://github.com/rust-analyzer/rust-analyzer/issues/1987#issuecomment-598807185 TL;DR: * 33% faster release build * slightly worse/same perf * no changes for debug build * slightly smaller binary cc @flodiebold I genuinely don't know if it is a good idea or not. Co-authored-by: Aleksey Kladov <[email protected]>
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))