From 080dd31f8460cba0298405fbcfcab8b61a4667ff Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 15 Nov 2019 19:14:50 +0300 Subject: Add ImplId --- crates/ra_hir_def/src/db.rs | 19 ++++++++++--------- crates/ra_hir_def/src/lib.rs | 12 ++++++++++++ 2 files changed, 22 insertions(+), 9 deletions(-) (limited to 'crates/ra_hir_def/src') 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::{ raw::{ImportSourceMap, RawItems}, CrateDefMap, }, - DefWithBodyId, EnumId, StructOrUnionId, + DefWithBodyId, EnumId, ItemLoc, StructOrUnionId, }; #[salsa::query_group(InternDatabaseStorage)] pub trait InternDatabase: SourceDatabase { #[salsa::interned] - fn intern_function(&self, loc: crate::ItemLoc) -> crate::FunctionId; + fn intern_function(&self, loc: ItemLoc) -> crate::FunctionId; #[salsa::interned] - fn intern_struct_or_union(&self, loc: crate::ItemLoc) - -> crate::StructOrUnionId; + fn intern_struct_or_union(&self, loc: ItemLoc) -> crate::StructOrUnionId; #[salsa::interned] - fn intern_enum(&self, loc: crate::ItemLoc) -> crate::EnumId; + fn intern_enum(&self, loc: ItemLoc) -> crate::EnumId; #[salsa::interned] - fn intern_const(&self, loc: crate::ItemLoc) -> crate::ConstId; + fn intern_const(&self, loc: ItemLoc) -> crate::ConstId; #[salsa::interned] - fn intern_static(&self, loc: crate::ItemLoc) -> crate::StaticId; + fn intern_static(&self, loc: ItemLoc) -> crate::StaticId; #[salsa::interned] - fn intern_trait(&self, loc: crate::ItemLoc) -> crate::TraitId; + fn intern_trait(&self, loc: ItemLoc) -> crate::TraitId; #[salsa::interned] - fn intern_type_alias(&self, loc: crate::ItemLoc) -> crate::TypeAliasId; + fn intern_type_alias(&self, loc: ItemLoc) -> crate::TypeAliasId; + #[salsa::interned] + fn intern_impl(&self, loc: ItemLoc) -> crate::ImplId; } #[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 for TypeAliasId { } } +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +pub struct ImplId(salsa::InternId); +impl_intern_key!(ImplId); +impl AstItemDef for ImplId { + fn intern(db: &impl InternDatabase, loc: ItemLoc) -> Self { + db.intern_impl(loc) + } + fn lookup_intern(self, db: &impl InternDatabase) -> ItemLoc { + db.lookup_intern_impl(self) + } +} + macro_rules! impl_froms { ($e:ident: $($v:ident $(($($sv:ident),*))?),*) => { $( -- cgit v1.2.3