aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r--crates/ra_hir/src/lib.rs2
-rw-r--r--crates/ra_hir/src/ty.rs14
2 files changed, 13 insertions, 3 deletions
diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs
index 59b402c57..8702c6222 100644
--- a/crates/ra_hir/src/lib.rs
+++ b/crates/ra_hir/src/lib.rs
@@ -60,7 +60,7 @@ pub use self::{
60 source_id::{AstIdMap, ErasedFileAstId}, 60 source_id::{AstIdMap, ErasedFileAstId},
61 ids::{HirFileId, MacroDefId, MacroCallId, MacroCallLoc}, 61 ids::{HirFileId, MacroDefId, MacroCallId, MacroCallLoc},
62 nameres::{PerNs, Namespace, ImportId}, 62 nameres::{PerNs, Namespace, ImportId},
63 ty::{Ty, ApplicationTy, TypeCtor, Substs, display::HirDisplay}, 63 ty::{Ty, ApplicationTy, TypeCtor, Substs, display::HirDisplay, CallableDef},
64 impl_block::{ImplBlock, ImplItem}, 64 impl_block::{ImplBlock, ImplItem},
65 docs::{Docs, Documentation}, 65 docs::{Docs, Documentation},
66 adt::AdtDef, 66 adt::AdtDef,
diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs
index 20e55d92d..ecf13fbc3 100644
--- a/crates/ra_hir/src/ty.rs
+++ b/crates/ra_hir/src/ty.rs
@@ -15,10 +15,11 @@ use std::sync::Arc;
15use std::{fmt, mem}; 15use std::{fmt, mem};
16 16
17use crate::{Name, AdtDef, type_ref::Mutability, db::HirDatabase, Trait}; 17use crate::{Name, AdtDef, type_ref::Mutability, db::HirDatabase, Trait};
18use display::{HirDisplay, HirFormatter};
18 19
19pub(crate) use lower::{TypableDef, CallableDef, type_for_def, type_for_field, callable_item_sig}; 20pub(crate) use lower::{TypableDef, type_for_def, type_for_field, callable_item_sig};
20pub(crate) use infer::{infer, InferenceResult, InferTy}; 21pub(crate) use infer::{infer, InferenceResult, InferTy};
21use display::{HirDisplay, HirFormatter}; 22pub use lower::CallableDef;
22 23
23/// A type constructor or type name: this might be something like the primitive 24/// A type constructor or type name: this might be something like the primitive
24/// type `bool`, a struct like `Vec`, or things like function pointers or 25/// type `bool`, a struct like `Vec`, or things like function pointers or
@@ -288,6 +289,15 @@ impl Ty {
288 } 289 }
289 } 290 }
290 291
292 pub fn as_callable(&self) -> Option<(CallableDef, &Substs)> {
293 match self {
294 Ty::Apply(ApplicationTy { ctor: TypeCtor::FnDef(callable_def), parameters }) => {
295 Some((*callable_def, parameters))
296 }
297 _ => None,
298 }
299 }
300
291 fn builtin_deref(&self) -> Option<Ty> { 301 fn builtin_deref(&self) -> Option<Ty> {
292 match self { 302 match self {
293 Ty::Apply(a_ty) => match a_ty.ctor { 303 Ty::Apply(a_ty) => match a_ty.ctor {