Skip to content

Commit fec2d39

Browse files
committed
simplify??
1 parent a1b2d25 commit fec2d39

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

crates/hir/src/source_analyzer.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ use hir_def::{
1515
},
1616
expr::{ExprId, Pat, PatId},
1717
path::{ModPath, Path, PathKind},
18-
resolver::{resolver_for_scope, HasResolver, Resolver, TypeNs, ValueNs},
19-
AsMacroCall, DefWithBodyId, FieldId, FunctionId, LocalFieldId, VariantId,
18+
resolver::{resolver_for_scope, Resolver, TypeNs, ValueNs},
19+
AsMacroCall, DefWithBodyId, FieldId, FunctionId, LocalFieldId, ModuleDefId, VariantId,
2020
};
2121
use hir_expand::{hygiene::Hygiene, name::AsName, HirFileId, InFile};
2222
use hir_ty::{
@@ -545,13 +545,13 @@ fn resolve_hir_path_(
545545
}
546546
}?;
547547

548-
if let (Some(_), TypeNs::TraitId(trait_id)) = (&unresolved, &ty) {
549-
let resolver = trait_id.resolver(db.upcast());
550-
if let Some(module_def_id) = resolver
551-
.resolve_module_path_in_trait_assoc_items(db.upcast(), path.mod_path())
552-
.and_then(|ns| ns.take_types())
548+
// If we are in a TypeNs for a Trait, and we have an unresolved name, try to resolve it as a type
549+
// within the trait's associated types.
550+
if let (Some(unresolved), &TypeNs::TraitId(trait_id)) = (&unresolved, &ty) {
551+
if let Some(type_alias_id) =
552+
db.trait_data(trait_id).associated_type_by_name(&unresolved.name)
553553
{
554-
return Some(PathResolution::Def(module_def_id.into()));
554+
return Some(PathResolution::Def(ModuleDefId::from(type_alias_id).into()));
555555
}
556556
}
557557

0 commit comments

Comments
 (0)