diff options
Diffstat (limited to 'crates/hir/src/code_model.rs')
-rw-r--r-- | crates/hir/src/code_model.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/crates/hir/src/code_model.rs b/crates/hir/src/code_model.rs index 68ccedc60..3d92d0c0d 100644 --- a/crates/hir/src/code_model.rs +++ b/crates/hir/src/code_model.rs | |||
@@ -12,6 +12,7 @@ use hir_def::{ | |||
12 | docs::Documentation, | 12 | docs::Documentation, |
13 | expr::{BindingAnnotation, Pat, PatId}, | 13 | expr::{BindingAnnotation, Pat, PatId}, |
14 | import_map, | 14 | import_map, |
15 | lang_item::LangItemTarget, | ||
15 | path::ModPath, | 16 | path::ModPath, |
16 | per_ns::PerNs, | 17 | per_ns::PerNs, |
17 | resolver::{HasResolver, Resolver}, | 18 | resolver::{HasResolver, Resolver}, |
@@ -36,7 +37,7 @@ use rustc_hash::FxHashSet; | |||
36 | use stdx::impl_from; | 37 | use stdx::impl_from; |
37 | use syntax::{ | 38 | use syntax::{ |
38 | ast::{self, AttrsOwner, NameOwner}, | 39 | ast::{self, AttrsOwner, NameOwner}, |
39 | AstNode, | 40 | AstNode, SmolStr, |
40 | }; | 41 | }; |
41 | 42 | ||
42 | use crate::{ | 43 | use crate::{ |
@@ -1287,6 +1288,15 @@ impl Type { | |||
1287 | db.trait_solve(self.krate, goal).is_some() | 1288 | db.trait_solve(self.krate, goal).is_some() |
1288 | } | 1289 | } |
1289 | 1290 | ||
1291 | pub fn is_copy(&self, db: &dyn HirDatabase) -> bool { | ||
1292 | let lang_item = db.lang_item(self.krate, SmolStr::new("copy")); | ||
1293 | let copy_trait = match lang_item { | ||
1294 | Some(LangItemTarget::TraitId(it)) => it, | ||
1295 | _ => return false, | ||
1296 | }; | ||
1297 | self.impls_trait(db, copy_trait.into(), &[]) | ||
1298 | } | ||
1299 | |||
1290 | pub fn as_callable(&self, db: &dyn HirDatabase) -> Option<Callable> { | 1300 | pub fn as_callable(&self, db: &dyn HirDatabase) -> Option<Callable> { |
1291 | let def = match self.ty.value { | 1301 | let def = match self.ty.value { |
1292 | Ty::Apply(ApplicationTy { ctor: TypeCtor::FnDef(def), parameters: _ }) => Some(def), | 1302 | Ty::Apply(ApplicationTy { ctor: TypeCtor::FnDef(def), parameters: _ }) => Some(def), |