diff options
Diffstat (limited to 'crates/ra_hir/src/from_id.rs')
-rw-r--r-- | crates/ra_hir/src/from_id.rs | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/crates/ra_hir/src/from_id.rs b/crates/ra_hir/src/from_id.rs index 5d7af00ab..529ac8251 100644 --- a/crates/ra_hir/src/from_id.rs +++ b/crates/ra_hir/src/from_id.rs | |||
@@ -4,14 +4,14 @@ | |||
4 | //! are splitting the hir. | 4 | //! are splitting the hir. |
5 | 5 | ||
6 | use hir_def::{ | 6 | use hir_def::{ |
7 | AdtId, AssocItemId, ConstId, DefWithBodyId, EnumId, EnumVariantId, FunctionId, GenericDefId, | 7 | AdtId, AssocItemId, AttrDefId, ConstId, DefWithBodyId, EnumId, EnumVariantId, FunctionId, |
8 | ModuleDefId, StaticId, StructFieldId, StructId, TypeAliasId, UnionId, VariantId, | 8 | GenericDefId, ModuleDefId, StaticId, StructFieldId, StructId, TypeAliasId, UnionId, VariantId, |
9 | }; | 9 | }; |
10 | 10 | ||
11 | use crate::{ | 11 | use crate::{ |
12 | ty::{CallableDef, TypableDef}, | 12 | ty::{CallableDef, TypableDef}, |
13 | Adt, AssocItem, Const, Crate, DefWithBody, EnumVariant, Function, GenericDef, ModuleDef, | 13 | Adt, AssocItem, AttrDef, Const, Crate, DefWithBody, EnumVariant, Function, GenericDef, |
14 | Static, StructField, TypeAlias, VariantDef, | 14 | ModuleDef, Static, StructField, TypeAlias, VariantDef, |
15 | }; | 15 | }; |
16 | 16 | ||
17 | impl From<ra_db::CrateId> for Crate { | 17 | impl From<ra_db::CrateId> for Crate { |
@@ -240,3 +240,20 @@ impl From<StructField> for StructFieldId { | |||
240 | StructFieldId { parent: def.parent.into(), local_id: def.id } | 240 | StructFieldId { parent: def.parent.into(), local_id: def.id } |
241 | } | 241 | } |
242 | } | 242 | } |
243 | |||
244 | impl From<AttrDef> for AttrDefId { | ||
245 | fn from(def: AttrDef) -> Self { | ||
246 | match def { | ||
247 | AttrDef::Module(it) => AttrDefId::ModuleId(it.id), | ||
248 | AttrDef::StructField(it) => AttrDefId::StructFieldId(it.into()), | ||
249 | AttrDef::Adt(it) => AttrDefId::AdtId(it.into()), | ||
250 | AttrDef::Function(it) => AttrDefId::FunctionId(it.id), | ||
251 | AttrDef::EnumVariant(it) => AttrDefId::EnumVariantId(it.into()), | ||
252 | AttrDef::Static(it) => AttrDefId::StaticId(it.id), | ||
253 | AttrDef::Const(it) => AttrDefId::ConstId(it.id), | ||
254 | AttrDef::Trait(it) => AttrDefId::TraitId(it.id), | ||
255 | AttrDef::TypeAlias(it) => AttrDefId::TypeAliasId(it.id), | ||
256 | AttrDef::MacroDef(it) => AttrDefId::MacroDefId(it.id), | ||
257 | } | ||
258 | } | ||
259 | } | ||