aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/from_id.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/from_id.rs')
-rw-r--r--crates/ra_hir/src/from_id.rs41
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
11use crate::{ 11use 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
17impl From<ra_db::CrateId> for Crate { 16impl From<ra_db::CrateId> for Crate {
@@ -138,20 +137,6 @@ impl From<GenericDef> for GenericDefId {
138 } 137 }
139} 138}
140 139
141impl 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
155impl From<AdtId> for TypableDef { 140impl 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
217impl 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
229impl From<VariantDef> for VariantId { 202impl 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
234impl 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}