mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
Better API factoring around self access modes
This commit is contained in:
parent
73f4fcbd0f
commit
61754678fb
4 changed files with 30 additions and 56 deletions
|
@ -12,6 +12,7 @@ use hir_def::{
|
|||
docs::Documentation,
|
||||
expr::{BindingAnnotation, Pat, PatId},
|
||||
import_map,
|
||||
lang_item::LangItemTarget,
|
||||
path::ModPath,
|
||||
per_ns::PerNs,
|
||||
resolver::{HasResolver, Resolver},
|
||||
|
@ -36,7 +37,7 @@ use rustc_hash::FxHashSet;
|
|||
use stdx::impl_from;
|
||||
use syntax::{
|
||||
ast::{self, AttrsOwner, NameOwner},
|
||||
AstNode,
|
||||
AstNode, SmolStr,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
|
@ -1287,6 +1288,15 @@ impl Type {
|
|||
db.trait_solve(self.krate, goal).is_some()
|
||||
}
|
||||
|
||||
pub fn is_copy(&self, db: &dyn HirDatabase) -> bool {
|
||||
let lang_item = db.lang_item(self.krate, SmolStr::new("copy"));
|
||||
let copy_trait = match lang_item {
|
||||
Some(LangItemTarget::TraitId(it)) => it,
|
||||
_ => return false,
|
||||
};
|
||||
self.impls_trait(db, copy_trait.into(), &[])
|
||||
}
|
||||
|
||||
pub fn as_callable(&self, db: &dyn HirDatabase) -> Option<Callable> {
|
||||
let def = match self.ty.value {
|
||||
Ty::Apply(ApplicationTy { ctor: TypeCtor::FnDef(def), parameters: _ }) => Some(def),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue