Add body as a possible container for items

This commit is contained in:
Aleksey Kladov 2019-12-19 18:12:46 +01:00
parent 5bd8de3f5e
commit ba12e83c26
5 changed files with 20 additions and 19 deletions

View file

@ -6,8 +6,8 @@ use std::sync::Arc;
use arrayvec::ArrayVec;
use hir_def::{
lang_item::LangItemTarget, resolver::Resolver, type_ref::Mutability, AssocItemId, FunctionId,
HasModule, ImplId, Lookup, TraitId,
lang_item::LangItemTarget, resolver::Resolver, type_ref::Mutability, AssocItemId, ContainerId,
FunctionId, HasModule, ImplId, Lookup, TraitId,
};
use hir_expand::name::Name;
use ra_db::CrateId;
@ -451,12 +451,12 @@ fn transform_receiver_ty(
self_ty: &Canonical<Ty>,
) -> Option<Ty> {
let substs = match function_id.lookup(db).container {
hir_def::ContainerId::TraitId(_) => Substs::build_for_def(db, function_id)
ContainerId::TraitId(_) => Substs::build_for_def(db, function_id)
.push(self_ty.value.clone())
.fill_with_unknown()
.build(),
hir_def::ContainerId::ImplId(impl_id) => inherent_impl_substs(db, impl_id, &self_ty)?,
hir_def::ContainerId::ModuleId(_) => unreachable!(),
ContainerId::ImplId(impl_id) => inherent_impl_substs(db, impl_id, &self_ty)?,
ContainerId::ModuleId(_) | ContainerId::DefWithBodyId(_) => unreachable!(),
};
let sig = db.callable_item_signature(function_id.into());
Some(sig.params()[0].clone().subst(&substs))