From ba12e83c26b24358e1bfbae0f913f8dfa13fc68f Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 19 Dec 2019 18:12:46 +0100 Subject: Add body as a possible container for items --- crates/ra_hir_ty/src/infer/path.rs | 2 +- crates/ra_hir_ty/src/method_resolution.rs | 10 +++++----- crates/ra_hir_ty/src/utils.rs | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'crates/ra_hir_ty/src') diff --git a/crates/ra_hir_ty/src/infer/path.rs b/crates/ra_hir_ty/src/infer/path.rs index 402a89386..31c90ea1e 100644 --- a/crates/ra_hir_ty/src/infer/path.rs +++ b/crates/ra_hir_ty/src/infer/path.rs @@ -237,7 +237,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { })); Some(substs) } - ContainerId::ModuleId(_) => None, + ContainerId::ModuleId(_) | ContainerId::DefWithBodyId(_) => None, }; self.write_assoc_resolution(id, item.into()); diff --git a/crates/ra_hir_ty/src/method_resolution.rs b/crates/ra_hir_ty/src/method_resolution.rs index 848e306e9..d0b2b016d 100644 --- a/crates/ra_hir_ty/src/method_resolution.rs +++ b/crates/ra_hir_ty/src/method_resolution.rs @@ -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, ) -> Option { 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)) diff --git a/crates/ra_hir_ty/src/utils.rs b/crates/ra_hir_ty/src/utils.rs index 29799a8cb..34defc1a2 100644 --- a/crates/ra_hir_ty/src/utils.rs +++ b/crates/ra_hir_ty/src/utils.rs @@ -157,6 +157,6 @@ fn parent_generic_def(db: &impl DefDatabase, def: GenericDefId) -> Option Some(it.into()), ContainerId::TraitId(it) => Some(it.into()), - ContainerId::ModuleId(_) => None, + ContainerId::ModuleId(_) | ContainerId::DefWithBodyId(_) => None, } } -- cgit v1.2.3