diff options
Diffstat (limited to 'crates/ra_hir/src/from_id.rs')
-rw-r--r-- | crates/ra_hir/src/from_id.rs | 41 |
1 files changed, 12 insertions, 29 deletions
diff --git a/crates/ra_hir/src/from_id.rs b/crates/ra_hir/src/from_id.rs index 529ac8251..619f6055e 100644 --- a/crates/ra_hir/src/from_id.rs +++ b/crates/ra_hir/src/from_id.rs | |||
@@ -9,9 +9,8 @@ use hir_def::{ | |||
9 | }; | 9 | }; |
10 | 10 | ||
11 | use crate::{ | 11 | use crate::{ |
12 | ty::{CallableDef, TypableDef}, | 12 | ty::TypableDef, Adt, AssocItem, AttrDef, Const, Crate, DefWithBody, EnumVariant, Function, |
13 | Adt, AssocItem, AttrDef, Const, Crate, DefWithBody, EnumVariant, Function, GenericDef, | 13 | GenericDef, ModuleDef, Static, StructField, TypeAlias, VariantDef, |
14 | ModuleDef, Static, StructField, TypeAlias, VariantDef, | ||
15 | }; | 14 | }; |
16 | 15 | ||
17 | impl From<ra_db::CrateId> for Crate { | 16 | impl From<ra_db::CrateId> for Crate { |
@@ -138,20 +137,6 @@ impl From<GenericDef> for GenericDefId { | |||
138 | } | 137 | } |
139 | } | 138 | } |
140 | 139 | ||
141 | impl From<GenericDefId> for GenericDef { | ||
142 | fn from(def: GenericDefId) -> Self { | ||
143 | match def { | ||
144 | GenericDefId::FunctionId(it) => GenericDef::Function(it.into()), | ||
145 | GenericDefId::AdtId(it) => GenericDef::Adt(it.into()), | ||
146 | GenericDefId::TraitId(it) => GenericDef::Trait(it.into()), | ||
147 | GenericDefId::TypeAliasId(it) => GenericDef::TypeAlias(it.into()), | ||
148 | GenericDefId::ImplId(it) => GenericDef::ImplBlock(it.into()), | ||
149 | GenericDefId::EnumVariantId(it) => GenericDef::EnumVariant(it.into()), | ||
150 | GenericDefId::ConstId(it) => GenericDef::Const(it.into()), | ||
151 | } | ||
152 | } | ||
153 | } | ||
154 | |||
155 | impl From<AdtId> for TypableDef { | 140 | impl From<AdtId> for TypableDef { |
156 | fn from(id: AdtId) -> Self { | 141 | fn from(id: AdtId) -> Self { |
157 | Adt::from(id).into() | 142 | Adt::from(id).into() |
@@ -214,18 +199,6 @@ impl From<Adt> for GenericDefId { | |||
214 | } | 199 | } |
215 | } | 200 | } |
216 | 201 | ||
217 | impl From<CallableDef> for GenericDefId { | ||
218 | fn from(def: CallableDef) -> Self { | ||
219 | match def { | ||
220 | CallableDef::Function(it) => it.id.into(), | ||
221 | CallableDef::Struct(it) => it.id.into(), | ||
222 | CallableDef::EnumVariant(it) => { | ||
223 | EnumVariantId { parent: it.parent.id, local_id: it.id }.into() | ||
224 | } | ||
225 | } | ||
226 | } | ||
227 | } | ||
228 | |||
229 | impl From<VariantDef> for VariantId { | 202 | impl From<VariantDef> for VariantId { |
230 | fn from(def: VariantDef) -> Self { | 203 | fn from(def: VariantDef) -> Self { |
231 | match def { | 204 | match def { |
@@ -257,3 +230,13 @@ impl From<AttrDef> for AttrDefId { | |||
257 | } | 230 | } |
258 | } | 231 | } |
259 | } | 232 | } |
233 | |||
234 | impl From<AssocItem> for GenericDefId { | ||
235 | fn from(item: AssocItem) -> Self { | ||
236 | match item { | ||
237 | AssocItem::Function(f) => f.id.into(), | ||
238 | AssocItem::Const(c) => c.id.into(), | ||
239 | AssocItem::TypeAlias(t) => t.id.into(), | ||
240 | } | ||
241 | } | ||
242 | } | ||