Get substs for trait refs in impl blocks
This commit is contained in:
@@ -10,15 +10,13 @@ use ra_syntax::{
|
||||
use crate::{
|
||||
Const, TypeAlias, Function, HirFileId,
|
||||
HirDatabase, DefDatabase,
|
||||
ModuleDef, Trait, Resolution,
|
||||
type_ref::TypeRef,
|
||||
ids::LocationCtx,
|
||||
resolve::Resolver,
|
||||
ty::Ty, generics::GenericParams,
|
||||
TraitRef, code_model_api::{Module, ModuleSource}
|
||||
};
|
||||
|
||||
use crate::code_model_api::{Module, ModuleSource};
|
||||
|
||||
#[derive(Debug, Default, PartialEq, Eq)]
|
||||
pub struct ImplSourceMap {
|
||||
map: ArenaMap<ImplId, AstPtr<ast::ImplBlock>>,
|
||||
@@ -73,7 +71,7 @@ impl ImplBlock {
|
||||
self.module
|
||||
}
|
||||
|
||||
pub fn target_trait_ref(&self, db: &impl DefDatabase) -> Option<TypeRef> {
|
||||
pub fn target_trait(&self, db: &impl DefDatabase) -> Option<TypeRef> {
|
||||
db.impls_in_module(self.module).impls[self.impl_id].target_trait().cloned()
|
||||
}
|
||||
|
||||
@@ -85,16 +83,8 @@ impl ImplBlock {
|
||||
Ty::from_hir(db, &self.resolver(db), &self.target_type(db))
|
||||
}
|
||||
|
||||
pub fn target_trait(&self, db: &impl HirDatabase) -> Option<Trait> {
|
||||
if let Some(TypeRef::Path(path)) = self.target_trait_ref(db) {
|
||||
let resolver = self.resolver(db);
|
||||
if let Some(Resolution::Def(ModuleDef::Trait(tr))) =
|
||||
resolver.resolve_path(db, &path).take_types()
|
||||
{
|
||||
return Some(tr);
|
||||
}
|
||||
}
|
||||
None
|
||||
pub fn target_trait_ref(&self, db: &impl HirDatabase) -> Option<TraitRef> {
|
||||
TraitRef::from_hir(db, &self.resolver(db), &self.target_trait(db)?)
|
||||
}
|
||||
|
||||
pub fn items(&self, db: &impl DefDatabase) -> Vec<ImplItem> {
|
||||
|
||||
Reference in New Issue
Block a user