aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/from_id.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-11-26 11:32:09 +0000
committerGitHub <[email protected]>2019-11-26 11:32:09 +0000
commit6e36eadd261b1f7765bef32ec74899003c5c3517 (patch)
tree5f05620adde03f7cb521b2f59aad6b2470e6272e /crates/ra_hir/src/from_id.rs
parent500e022f7decbee29a693b0f0dd2f63789a99e5a (diff)
parenta443b5033c2e95ee58bf086f7093ddc610d4f78f (diff)
Merge #2409
2409: Id-ify Ty::Adt r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/from_id.rs')
-rw-r--r--crates/ra_hir/src/from_id.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/crates/ra_hir/src/from_id.rs b/crates/ra_hir/src/from_id.rs
index 619f6055e..38daa5e59 100644
--- a/crates/ra_hir/src/from_id.rs
+++ b/crates/ra_hir/src/from_id.rs
@@ -199,11 +199,22 @@ impl From<Adt> for GenericDefId {
199 } 199 }
200} 200}
201 201
202impl From<VariantId> for VariantDef {
203 fn from(def: VariantId) -> Self {
204 match def {
205 VariantId::StructId(it) => VariantDef::Struct(it.into()),
206 VariantId::EnumVariantId(it) => VariantDef::EnumVariant(it.into()),
207 VariantId::UnionId(it) => VariantDef::Union(it.into()),
208 }
209 }
210}
211
202impl From<VariantDef> for VariantId { 212impl From<VariantDef> for VariantId {
203 fn from(def: VariantDef) -> Self { 213 fn from(def: VariantDef) -> Self {
204 match def { 214 match def {
205 VariantDef::Struct(it) => VariantId::StructId(it.id), 215 VariantDef::Struct(it) => VariantId::StructId(it.id),
206 VariantDef::EnumVariant(it) => VariantId::EnumVariantId(it.into()), 216 VariantDef::EnumVariant(it) => VariantId::EnumVariantId(it.into()),
217 VariantDef::Union(it) => VariantId::UnionId(it.id),
207 } 218 }
208 } 219 }
209} 220}
@@ -214,6 +225,12 @@ impl From<StructField> for StructFieldId {
214 } 225 }
215} 226}
216 227
228impl From<StructFieldId> for StructField {
229 fn from(def: StructFieldId) -> Self {
230 StructField { parent: def.parent.into(), id: def.local_id }
231 }
232}
233
217impl From<AttrDef> for AttrDefId { 234impl From<AttrDef> for AttrDefId {
218 fn from(def: AttrDef) -> Self { 235 fn from(def: AttrDef) -> Self {
219 match def { 236 match def {