From 48f65b3b157a5b974be6252dd8fc9ffc158d4217 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Fri, 11 Jun 2021 19:23:59 +0200 Subject: Item search now respects trait impl items --- crates/hir/src/lib.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'crates/hir/src') diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index debc3ee62..68ac8400c 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -1450,6 +1450,20 @@ impl AssocItem { _ => None, } } + + pub fn containing_trait_impl(self, db: &dyn HirDatabase) -> Option { + match self.container(db) { + AssocItemContainer::Impl(i) => i.trait_(db), + _ => None, + } + } + + pub fn containing_trait_or_trait_impl(self, db: &dyn HirDatabase) -> Option { + match self.container(db) { + AssocItemContainer::Trait(t) => Some(t), + AssocItemContainer::Impl(i) => i.trait_(db), + } + } } impl HasVisibility for AssocItem { -- cgit v1.2.3