diff options
Diffstat (limited to 'crates/ra_hir/src/ty.rs')
-rw-r--r-- | crates/ra_hir/src/ty.rs | 14 |
1 files changed, 12 insertions, 2 deletions
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; | |||
15 | use std::{fmt, mem}; | 15 | use std::{fmt, mem}; |
16 | 16 | ||
17 | use crate::{Name, AdtDef, type_ref::Mutability, db::HirDatabase, Trait}; | 17 | use crate::{Name, AdtDef, type_ref::Mutability, db::HirDatabase, Trait}; |
18 | use display::{HirDisplay, HirFormatter}; | ||
18 | 19 | ||
19 | pub(crate) use lower::{TypableDef, CallableDef, type_for_def, type_for_field, callable_item_sig}; | 20 | pub(crate) use lower::{TypableDef, type_for_def, type_for_field, callable_item_sig}; |
20 | pub(crate) use infer::{infer, InferenceResult, InferTy}; | 21 | pub(crate) use infer::{infer, InferenceResult, InferTy}; |
21 | use display::{HirDisplay, HirFormatter}; | 22 | pub 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 { |