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/ide/src/display/navigation_target.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'crates/ide/src/display/navigation_target.rs') diff --git a/crates/ide/src/display/navigation_target.rs b/crates/ide/src/display/navigation_target.rs index e24c78301..4eecae697 100644 --- a/crates/ide/src/display/navigation_target.rs +++ b/crates/ide/src/display/navigation_target.rs @@ -215,10 +215,8 @@ impl TryToNav for Definition { Definition::ModuleDef(it) => it.try_to_nav(db), Definition::SelfType(it) => it.try_to_nav(db), Definition::Local(it) => Some(it.to_nav(db)), - Definition::TypeParam(it) => it.try_to_nav(db), - Definition::LifetimeParam(it) => it.try_to_nav(db), + Definition::GenericParam(it) => it.try_to_nav(db), Definition::Label(it) => Some(it.to_nav(db)), - Definition::ConstParam(it) => it.try_to_nav(db), } } } @@ -389,6 +387,16 @@ impl TryToNav for hir::AssocItem { } } +impl TryToNav for hir::GenericParam { + fn try_to_nav(&self, db: &RootDatabase) -> Option { + match self { + hir::GenericParam::TypeParam(it) => it.try_to_nav(db), + hir::GenericParam::ConstParam(it) => it.try_to_nav(db), + hir::GenericParam::LifetimeParam(it) => it.try_to_nav(db), + } + } +} + impl ToNav for hir::Local { fn to_nav(&self, db: &RootDatabase) -> NavigationTarget { let src = self.source(db); -- cgit v1.2.3