diff options
Diffstat (limited to 'crates/hir/src')
-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 b9c1dc44d..0bb3767c1 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs | |||
@@ -1451,6 +1451,20 @@ impl AssocItem { | |||
1451 | _ => None, | 1451 | _ => None, |
1452 | } | 1452 | } |
1453 | } | 1453 | } |
1454 | |||
1455 | pub fn containing_trait_impl(self, db: &dyn HirDatabase) -> Option<Trait> { | ||
1456 | match self.container(db) { | ||
1457 | AssocItemContainer::Impl(i) => i.trait_(db), | ||
1458 | _ => None, | ||
1459 | } | ||
1460 | } | ||
1461 | |||
1462 | pub fn containing_trait_or_trait_impl(self, db: &dyn HirDatabase) -> Option<Trait> { | ||
1463 | match self.container(db) { | ||
1464 | AssocItemContainer::Trait(t) => Some(t), | ||
1465 | AssocItemContainer::Impl(i) => i.trait_(db), | ||
1466 | } | ||
1467 | } | ||
1454 | } | 1468 | } |
1455 | 1469 | ||
1456 | impl HasVisibility for AssocItem { | 1470 | impl HasVisibility for AssocItem { |