diff options
Diffstat (limited to 'crates/hir/src/lib.rs')
-rw-r--r-- | crates/hir/src/lib.rs | 14 |
1 files changed, 14 insertions, 0 deletions
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 { | |||
1450 | _ => None, | 1450 | _ => None, |
1451 | } | 1451 | } |
1452 | } | 1452 | } |
1453 | |||
1454 | pub fn containing_trait_impl(self, db: &dyn HirDatabase) -> Option<Trait> { | ||
1455 | match self.container(db) { | ||
1456 | AssocItemContainer::Impl(i) => i.trait_(db), | ||
1457 | _ => None, | ||
1458 | } | ||
1459 | } | ||
1460 | |||
1461 | pub fn containing_trait_or_trait_impl(self, db: &dyn HirDatabase) -> Option<Trait> { | ||
1462 | match self.container(db) { | ||
1463 | AssocItemContainer::Trait(t) => Some(t), | ||
1464 | AssocItemContainer::Impl(i) => i.trait_(db), | ||
1465 | } | ||
1466 | } | ||
1453 | } | 1467 | } |
1454 | 1468 | ||
1455 | impl HasVisibility for AssocItem { | 1469 | impl HasVisibility for AssocItem { |