From 0102fb41337ac0442e689d410bb424d215e9a7bd Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 21 Nov 2019 12:21:46 +0300 Subject: Decouple Resolver --- crates/ra_hir/src/code_model.rs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'crates/ra_hir/src/code_model.rs') diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index a132d128b..550ab1a98 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs @@ -12,8 +12,8 @@ use hir_def::{ builtin_type::BuiltinType, traits::TraitData, type_ref::{Mutability, TypeRef}, - AssocItemId, ContainerId, CrateModuleId, HasModule, ImplId, LocalEnumVariantId, - LocalStructFieldId, Lookup, ModuleId, UnionId, + ContainerId, CrateModuleId, HasModule, ImplId, LocalEnumVariantId, LocalStructFieldId, Lookup, + ModuleId, UnionId, }; use hir_expand::{ diagnostics::DiagnosticSink, @@ -842,9 +842,10 @@ impl Trait { _ => None, }) .filter_map(|path| match resolver.resolve_path_in_type_ns_fully(db, path) { - Some(TypeNs::Trait(t)) => Some(t), + Some(TypeNs::TraitId(t)) => Some(t), _ => None, }) + .map(Trait::from) .collect() } @@ -871,14 +872,9 @@ impl Trait { pub fn associated_type_by_name(self, db: &impl DefDatabase, name: &Name) -> Option { let trait_data = self.trait_data(db); - trait_data - .items - .iter() - .filter_map(|item| match item { - AssocItemId::TypeAliasId(t) => Some(TypeAlias::from(*t)), - _ => None, - }) - .find(|t| &t.name(db) == name) + let res = + trait_data.associated_types().map(TypeAlias::from).find(|t| &t.name(db) == name)?; + Some(res) } pub fn associated_type_by_name_including_super_traits( -- cgit v1.2.3