@@ -15,8 +15,8 @@ use hir_def::{
15
15
} ,
16
16
expr:: { ExprId , Pat , PatId } ,
17
17
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 ,
20
20
} ;
21
21
use hir_expand:: { hygiene:: Hygiene , name:: AsName , HirFileId , InFile } ;
22
22
use hir_ty:: {
@@ -545,13 +545,13 @@ fn resolve_hir_path_(
545
545
}
546
546
} ?;
547
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 ( ) )
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 )
553
553
{
554
- return Some ( PathResolution :: Def ( module_def_id . into ( ) ) ) ;
554
+ return Some ( PathResolution :: Def ( ModuleDefId :: from ( type_alias_id ) . into ( ) ) ) ;
555
555
}
556
556
}
557
557
0 commit comments