aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty/src/lib.rs')
-rw-r--r--crates/hir_ty/src/lib.rs19
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};
29use hir_def::{ 29use 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};
35use itertools::Itertools; 35use itertools::Itertools;
36 36
@@ -43,10 +43,9 @@ use crate::{
43 43
44pub use autoderef::autoderef; 44pub use autoderef::autoderef;
45pub use infer::{InferTy, InferenceResult}; 45pub use infer::{InferTy, InferenceResult};
46pub use lower::CallableDefId;
47pub use lower::{ 46pub 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};
51pub use traits::{InEnvironment, Obligation, ProjectionPredicate, TraitEnvironment}; 50pub 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 {