From c82d1823a1624f4990b1ebaba5b6173f15631381 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sat, 13 Mar 2021 20:38:11 +0100 Subject: Create TraitEnvironment through a query --- crates/hir_def/src/lib.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'crates/hir_def') diff --git a/crates/hir_def/src/lib.rs b/crates/hir_def/src/lib.rs index 6d11c5be4..c6655c5fb 100644 --- a/crates/hir_def/src/lib.rs +++ b/crates/hir_def/src/lib.rs @@ -341,6 +341,16 @@ pub enum DefWithBodyId { impl_from!(FunctionId, ConstId, StaticId for DefWithBodyId); +impl DefWithBodyId { + pub fn as_generic_def_id(self) -> Option { + match self { + DefWithBodyId::FunctionId(f) => Some(f.into()), + DefWithBodyId::StaticId(_) => None, + DefWithBodyId::ConstId(c) => Some(c.into()), + } + } +} + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum AssocItemId { FunctionId(FunctionId), -- cgit v1.2.3