aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_def/src/lib.rs')
-rw-r--r--crates/ra_hir_def/src/lib.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs
index 3fab7965c..0a59c4ad7 100644
--- a/crates/ra_hir_def/src/lib.rs
+++ b/crates/ra_hir_def/src/lib.rs
@@ -13,6 +13,7 @@ pub mod path;
13pub mod type_ref; 13pub mod type_ref;
14pub mod builtin_type; 14pub mod builtin_type;
15pub mod adt; 15pub mod adt;
16pub mod imp;
16pub mod diagnostics; 17pub mod diagnostics;
17pub mod expr; 18pub mod expr;
18pub mod body; 19pub mod body;
@@ -321,6 +322,18 @@ impl AstItemDef<ast::TypeAliasDef> for TypeAliasId {
321 } 322 }
322} 323}
323 324
325#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
326pub struct ImplId(salsa::InternId);
327impl_intern_key!(ImplId);
328impl AstItemDef<ast::ImplBlock> for ImplId {
329 fn intern(db: &impl InternDatabase, loc: ItemLoc<ast::ImplBlock>) -> Self {
330 db.intern_impl(loc)
331 }
332 fn lookup_intern(self, db: &impl InternDatabase) -> ItemLoc<ast::ImplBlock> {
333 db.lookup_intern_impl(self)
334 }
335}
336
324macro_rules! impl_froms { 337macro_rules! impl_froms {
325 ($e:ident: $($v:ident $(($($sv:ident),*))?),*) => { 338 ($e:ident: $($v:ident $(($($sv:ident),*))?),*) => {
326 $( 339 $(
@@ -384,3 +397,15 @@ pub enum DefWithBodyId {
384} 397}
385 398
386impl_froms!(DefWithBodyId: FunctionId, ConstId, StaticId); 399impl_froms!(DefWithBodyId: FunctionId, ConstId, StaticId);
400
401#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
402pub enum AssocItemId {
403 FunctionId(FunctionId),
404 ConstId(ConstId),
405 TypeAliasId(TypeAliasId),
406}
407// FIXME: not every function, ... is actually an assoc item. maybe we should make
408// sure that you can only turn actual assoc items into AssocItemIds. This would
409// require not implementing From, and instead having some checked way of
410// casting them, and somehow making the constructors private, which would be annoying.
411impl_froms!(AssocItemId: FunctionId, ConstId, TypeAliasId);