diff options
Diffstat (limited to 'crates/ra_hir_def/src/nameres/raw.rs')
-rw-r--r-- | crates/ra_hir_def/src/nameres/raw.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/crates/ra_hir_def/src/nameres/raw.rs b/crates/ra_hir_def/src/nameres/raw.rs index de4e706c2..a2821e1c3 100644 --- a/crates/ra_hir_def/src/nameres/raw.rs +++ b/crates/ra_hir_def/src/nameres/raw.rs | |||
@@ -184,6 +184,21 @@ pub(super) enum DefKind { | |||
184 | TypeAlias(FileAstId<ast::TypeAliasDef>), | 184 | TypeAlias(FileAstId<ast::TypeAliasDef>), |
185 | } | 185 | } |
186 | 186 | ||
187 | impl DefKind { | ||
188 | pub fn ast_id(&self) -> FileAstId<ast::ModuleItem> { | ||
189 | match self { | ||
190 | DefKind::Function(it) => it.upcast(), | ||
191 | DefKind::Struct(it) => it.upcast(), | ||
192 | DefKind::Union(it) => it.upcast(), | ||
193 | DefKind::Enum(it) => it.upcast(), | ||
194 | DefKind::Const(it) => it.upcast(), | ||
195 | DefKind::Static(it) => it.upcast(), | ||
196 | DefKind::Trait(it) => it.upcast(), | ||
197 | DefKind::TypeAlias(it) => it.upcast(), | ||
198 | } | ||
199 | } | ||
200 | } | ||
201 | |||
187 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 202 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
188 | pub(super) struct Macro(RawId); | 203 | pub(super) struct Macro(RawId); |
189 | impl_arena_id!(Macro); | 204 | impl_arena_id!(Macro); |