diff options
Diffstat (limited to 'crates/hir_ty/src/lib.rs')
-rw-r--r-- | crates/hir_ty/src/lib.rs | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/crates/hir_ty/src/lib.rs b/crates/hir_ty/src/lib.rs index d47f975d2..6bec389f8 100644 --- a/crates/hir_ty/src/lib.rs +++ b/crates/hir_ty/src/lib.rs | |||
@@ -29,8 +29,8 @@ use base_db::{salsa, CrateId}; | |||
29 | use hir_def::{ | 29 | use hir_def::{ |
30 | expr::ExprId, | 30 | expr::ExprId, |
31 | type_ref::{Mutability, Rawness}, | 31 | type_ref::{Mutability, Rawness}, |
32 | AdtId, AssocContainerId, DefWithBodyId, GenericDefId, HasModule, LifetimeParamId, Lookup, | 32 | AdtId, AssocContainerId, DefWithBodyId, FunctionId, GenericDefId, HasModule, LifetimeParamId, |
33 | TraitId, TypeAliasId, TypeParamId, | 33 | Lookup, TraitId, TypeAliasId, TypeParamId, |
34 | }; | 34 | }; |
35 | use itertools::Itertools; | 35 | use itertools::Itertools; |
36 | 36 | ||
@@ -43,10 +43,9 @@ use crate::{ | |||
43 | 43 | ||
44 | pub use autoderef::autoderef; | 44 | pub use autoderef::autoderef; |
45 | pub use infer::{InferTy, InferenceResult}; | 45 | pub use infer::{InferTy, InferenceResult}; |
46 | pub use lower::CallableDefId; | ||
47 | pub use lower::{ | 46 | pub use lower::{ |
48 | associated_type_shorthand_candidates, callable_item_sig, ImplTraitLoweringMode, TyDefId, | 47 | associated_type_shorthand_candidates, callable_item_sig, CallableDefId, ImplTraitLoweringMode, |
49 | TyLoweringContext, ValueTyDefId, | 48 | TyDefId, TyLoweringContext, ValueTyDefId, |
50 | }; | 49 | }; |
51 | pub use traits::{InEnvironment, Obligation, ProjectionPredicate, TraitEnvironment}; | 50 | pub use traits::{InEnvironment, Obligation, ProjectionPredicate, TraitEnvironment}; |
52 | 51 | ||
@@ -824,6 +823,16 @@ impl Ty { | |||
824 | } | 823 | } |
825 | } | 824 | } |
826 | 825 | ||
826 | pub fn as_fn_def(&self) -> Option<FunctionId> { | ||
827 | match self { | ||
828 | &Ty::Apply(ApplicationTy { | ||
829 | ctor: TypeCtor::FnDef(CallableDefId::FunctionId(func)), | ||
830 | .. | ||
831 | }) => Some(func), | ||
832 | _ => None, | ||
833 | } | ||
834 | } | ||
835 | |||
827 | pub fn callable_sig(&self, db: &dyn HirDatabase) -> Option<FnSig> { | 836 | pub fn callable_sig(&self, db: &dyn HirDatabase) -> Option<FnSig> { |
828 | match self { | 837 | match self { |
829 | Ty::Apply(a_ty) => match a_ty.ctor { | 838 | Ty::Apply(a_ty) => match a_ty.ctor { |