Skip to content

Commit a1b2d25

Browse files
committed
hir: resolve assoc trait type
1 parent 2d0db31 commit a1b2d25

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

crates/hir/src/source_analyzer.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use hir_def::{
1515
},
1616
expr::{ExprId, Pat, PatId},
1717
path::{ModPath, Path, PathKind},
18-
resolver::{resolver_for_scope, Resolver, TypeNs, ValueNs},
18+
resolver::{resolver_for_scope, HasResolver, Resolver, TypeNs, ValueNs},
1919
AsMacroCall, DefWithBodyId, FieldId, FunctionId, LocalFieldId, VariantId,
2020
};
2121
use hir_expand::{hygiene::Hygiene, name::AsName, HirFileId, InFile};
@@ -544,6 +544,17 @@ fn resolve_hir_path_(
544544
}
545545
}
546546
}?;
547+
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())
553+
{
554+
return Some(PathResolution::Def(module_def_id.into()));
555+
}
556+
}
557+
547558
let res = match ty {
548559
TypeNs::SelfType(it) => PathResolution::SelfType(it.into()),
549560
TypeNs::GenericParam(id) => PathResolution::TypeParam(TypeParam { id }),

0 commit comments

Comments
 (0)