From b795128dde24cd3c4ec45879b354ec8c60fc751b Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Fri, 8 Jan 2021 12:28:02 +0100 Subject: Use hir::GenericParam in ide_db::Definition instead of relisting all 3 --- crates/hir/src/code_model.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'crates/hir') diff --git a/crates/hir/src/code_model.rs b/crates/hir/src/code_model.rs index cc1938333..6cbf5cecf 100644 --- a/crates/hir/src/code_model.rs +++ b/crates/hir/src/code_model.rs @@ -1263,6 +1263,24 @@ pub enum GenericParam { } impl_from!(TypeParam, LifetimeParam, ConstParam for GenericParam); +impl GenericParam { + pub fn module(self, db: &dyn HirDatabase) -> Module { + match self { + GenericParam::TypeParam(it) => it.module(db), + GenericParam::LifetimeParam(it) => it.module(db), + GenericParam::ConstParam(it) => it.module(db), + } + } + + pub fn name(self, db: &dyn HirDatabase) -> Name { + match self { + GenericParam::TypeParam(it) => it.name(db), + GenericParam::LifetimeParam(it) => it.name(db), + GenericParam::ConstParam(it) => it.name(db), + } + } +} + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub struct TypeParam { pub(crate) id: TypeParamId, -- cgit v1.2.3