From 18f6a995d0fc1f45099f3cc810a5d55d5401b41b Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Thu, 5 Dec 2019 15:10:33 +0100 Subject: Add expansion infrastructure for derive macros --- crates/ra_hir_def/src/nameres/raw.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'crates/ra_hir_def/src/nameres/raw.rs') 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 { TypeAlias(FileAstId), } +impl DefKind { + pub fn ast_id(&self) -> FileAstId { + match self { + DefKind::Function(it) => it.upcast(), + DefKind::Struct(it) => it.upcast(), + DefKind::Union(it) => it.upcast(), + DefKind::Enum(it) => it.upcast(), + DefKind::Const(it) => it.upcast(), + DefKind::Static(it) => it.upcast(), + DefKind::Trait(it) => it.upcast(), + DefKind::TypeAlias(it) => it.upcast(), + } + } +} + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub(super) struct Macro(RawId); impl_arena_id!(Macro); -- cgit v1.2.3