aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_hir_def/src/db.rs19
-rw-r--r--crates/ra_hir_def/src/lib.rs12
2 files changed, 22 insertions, 9 deletions
diff --git a/crates/ra_hir_def/src/db.rs b/crates/ra_hir_def/src/db.rs
index 40b5920d9..40e68a3c3 100644
--- a/crates/ra_hir_def/src/db.rs
+++ b/crates/ra_hir_def/src/db.rs
@@ -12,26 +12,27 @@ use crate::{
12 raw::{ImportSourceMap, RawItems}, 12 raw::{ImportSourceMap, RawItems},
13 CrateDefMap, 13 CrateDefMap,
14 }, 14 },
15 DefWithBodyId, EnumId, StructOrUnionId, 15 DefWithBodyId, EnumId, ItemLoc, StructOrUnionId,
16}; 16};
17 17
18#[salsa::query_group(InternDatabaseStorage)] 18#[salsa::query_group(InternDatabaseStorage)]
19pub trait InternDatabase: SourceDatabase { 19pub trait InternDatabase: SourceDatabase {
20 #[salsa::interned] 20 #[salsa::interned]
21 fn intern_function(&self, loc: crate::ItemLoc<ast::FnDef>) -> crate::FunctionId; 21 fn intern_function(&self, loc: ItemLoc<ast::FnDef>) -> crate::FunctionId;
22 #[salsa::interned] 22 #[salsa::interned]
23 fn intern_struct_or_union(&self, loc: crate::ItemLoc<ast::StructDef>) 23 fn intern_struct_or_union(&self, loc: ItemLoc<ast::StructDef>) -> crate::StructOrUnionId;
24 -> crate::StructOrUnionId;
25 #[salsa::interned] 24 #[salsa::interned]
26 fn intern_enum(&self, loc: crate::ItemLoc<ast::EnumDef>) -> crate::EnumId; 25 fn intern_enum(&self, loc: ItemLoc<ast::EnumDef>) -> crate::EnumId;
27 #[salsa::interned] 26 #[salsa::interned]
28 fn intern_const(&self, loc: crate::ItemLoc<ast::ConstDef>) -> crate::ConstId; 27 fn intern_const(&self, loc: ItemLoc<ast::ConstDef>) -> crate::ConstId;
29 #[salsa::interned] 28 #[salsa::interned]
30 fn intern_static(&self, loc: crate::ItemLoc<ast::StaticDef>) -> crate::StaticId; 29 fn intern_static(&self, loc: ItemLoc<ast::StaticDef>) -> crate::StaticId;
31 #[salsa::interned] 30 #[salsa::interned]
32 fn intern_trait(&self, loc: crate::ItemLoc<ast::TraitDef>) -> crate::TraitId; 31 fn intern_trait(&self, loc: ItemLoc<ast::TraitDef>) -> crate::TraitId;
33 #[salsa::interned] 32 #[salsa::interned]
34 fn intern_type_alias(&self, loc: crate::ItemLoc<ast::TypeAliasDef>) -> crate::TypeAliasId; 33 fn intern_type_alias(&self, loc: ItemLoc<ast::TypeAliasDef>) -> crate::TypeAliasId;
34 #[salsa::interned]
35 fn intern_impl(&self, loc: ItemLoc<ast::ImplBlock>) -> crate::ImplId;
35} 36}
36 37
37#[salsa::query_group(DefDatabase2Storage)] 38#[salsa::query_group(DefDatabase2Storage)]
diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs
index 3fab7965c..22650db8b 100644
--- a/crates/ra_hir_def/src/lib.rs
+++ b/crates/ra_hir_def/src/lib.rs
@@ -321,6 +321,18 @@ impl AstItemDef<ast::TypeAliasDef> for TypeAliasId {
321 } 321 }
322} 322}
323 323
324#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
325pub struct ImplId(salsa::InternId);
326impl_intern_key!(ImplId);
327impl AstItemDef<ast::ImplBlock> for ImplId {
328 fn intern(db: &impl InternDatabase, loc: ItemLoc<ast::ImplBlock>) -> Self {
329 db.intern_impl(loc)
330 }
331 fn lookup_intern(self, db: &impl InternDatabase) -> ItemLoc<ast::ImplBlock> {
332 db.lookup_intern_impl(self)
333 }
334}
335
324macro_rules! impl_froms { 336macro_rules! impl_froms {
325 ($e:ident: $($v:ident $(($($sv:ident),*))?),*) => { 337 ($e:ident: $($v:ident $(($($sv:ident),*))?),*) => {
326 $( 338 $(