diff options
Diffstat (limited to 'crates/ra_hir/src/from_id.rs')
-rw-r--r-- | crates/ra_hir/src/from_id.rs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/crates/ra_hir/src/from_id.rs b/crates/ra_hir/src/from_id.rs index 089dbc908..9633ef586 100644 --- a/crates/ra_hir/src/from_id.rs +++ b/crates/ra_hir/src/from_id.rs | |||
@@ -3,9 +3,9 @@ | |||
3 | //! It's unclear if we need this long-term, but it's definitelly useful while we | 3 | //! It's unclear if we need this long-term, but it's definitelly useful while we |
4 | //! are splitting the hir. | 4 | //! are splitting the hir. |
5 | 5 | ||
6 | use hir_def::{AdtId, EnumVariantId, ModuleDefId}; | 6 | use hir_def::{AdtId, DefWithBodyId, EnumVariantId, ModuleDefId}; |
7 | 7 | ||
8 | use crate::{Adt, EnumVariant, ModuleDef}; | 8 | use crate::{Adt, DefWithBody, EnumVariant, ModuleDef}; |
9 | 9 | ||
10 | macro_rules! from_id { | 10 | macro_rules! from_id { |
11 | ($(($id:path, $ty:path)),*) => {$( | 11 | ($(($id:path, $ty:path)),*) => {$( |
@@ -61,3 +61,13 @@ impl From<ModuleDefId> for ModuleDef { | |||
61 | } | 61 | } |
62 | } | 62 | } |
63 | } | 63 | } |
64 | |||
65 | impl From<DefWithBody> for DefWithBodyId { | ||
66 | fn from(def: DefWithBody) -> Self { | ||
67 | match def { | ||
68 | DefWithBody::Function(it) => DefWithBodyId::FunctionId(it.id), | ||
69 | DefWithBody::Static(it) => DefWithBodyId::StaticId(it.id), | ||
70 | DefWithBody::Const(it) => DefWithBodyId::ConstId(it.id), | ||
71 | } | ||
72 | } | ||
73 | } | ||