diff options
Diffstat (limited to 'crates/hir/src')
-rw-r--r-- | crates/hir/src/code_model.rs | 9 | ||||
-rw-r--r-- | crates/hir/src/lib.rs | 4 |
2 files changed, 10 insertions, 3 deletions
diff --git a/crates/hir/src/code_model.rs b/crates/hir/src/code_model.rs index 1dd6d73f3..0b24f247c 100644 --- a/crates/hir/src/code_model.rs +++ b/crates/hir/src/code_model.rs | |||
@@ -772,7 +772,14 @@ impl Function { | |||
772 | hir_ty::diagnostics::validate_body(db, self.id.into(), sink) | 772 | hir_ty::diagnostics::validate_body(db, self.id.into(), sink) |
773 | } | 773 | } |
774 | 774 | ||
775 | pub fn parent_def(self, db: &dyn HirDatabase) -> Option<MethodOwner> { | 775 | /// Whether this function declaration has a definition. |
776 | /// | ||
777 | /// This is false in the case of required (not provided) trait methods. | ||
778 | pub fn has_body(self, db: &dyn HirDatabase) -> bool { | ||
779 | db.function_data(self.id).has_body | ||
780 | } | ||
781 | |||
782 | pub fn method_owner(self, db: &dyn HirDatabase) -> Option<MethodOwner> { | ||
776 | match self.as_assoc_item(db).map(|assoc| assoc.container(db)) { | 783 | match self.as_assoc_item(db).map(|assoc| assoc.container(db)) { |
777 | Some(AssocItemContainer::Trait(t)) => Some(t.into()), | 784 | Some(AssocItemContainer::Trait(t)) => Some(t.into()), |
778 | Some(AssocItemContainer::ImplDef(imp)) => { | 785 | Some(AssocItemContainer::ImplDef(imp)) => { |
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index 4094a76cb..687abe6ca 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs | |||
@@ -35,8 +35,8 @@ pub use crate::{ | |||
35 | code_model::{ | 35 | code_model::{ |
36 | Access, Adt, AsAssocItem, AssocItem, AssocItemContainer, Callable, CallableKind, Const, | 36 | Access, Adt, AsAssocItem, AssocItem, AssocItemContainer, Callable, CallableKind, Const, |
37 | Crate, CrateDependency, DefWithBody, Enum, EnumVariant, Field, FieldSource, Function, | 37 | Crate, CrateDependency, DefWithBody, Enum, EnumVariant, Field, FieldSource, Function, |
38 | GenericDef, HasVisibility, ImplDef, Local, MacroDef, Module, ModuleDef, ScopeDef, Static, | 38 | GenericDef, HasVisibility, ImplDef, Local, MacroDef, MethodOwner, Module, ModuleDef, |
39 | Struct, Trait, Type, TypeAlias, TypeParam, Union, VariantDef, Visibility, | 39 | ScopeDef, Static, Struct, Trait, Type, TypeAlias, TypeParam, Union, VariantDef, Visibility, |
40 | }, | 40 | }, |
41 | has_source::HasSource, | 41 | has_source::HasSource, |
42 | semantics::{original_range, PathResolution, Semantics, SemanticsScope}, | 42 | semantics::{original_range, PathResolution, Semantics, SemanticsScope}, |