@@ -3,7 +3,7 @@ use std::{mem, ops::Not};
33
44use either:: Either ;
55use hir:: {
6- db:: ExpandDatabase , Adt , AsAssocItem , AsExternAssocItem , CaptureKind ,
6+ db:: ExpandDatabase , Adt , AsAssocItem , AsExternAssocItem , AssocItemContainer , CaptureKind ,
77 DynCompatibilityViolation , HasCrate , HasSource , HirDisplay , Layout , LayoutError ,
88 MethodViolationCode , Name , Semantics , Trait , Type , TypeInfo ,
99} ;
@@ -813,7 +813,15 @@ fn definition_mod_path(db: &RootDatabase, def: &Definition, edition: Edition) ->
813813 if matches ! ( def, Definition :: GenericParam ( _) | Definition :: Local ( _) | Definition :: Label ( _) ) {
814814 return None ;
815815 }
816- def. module ( db) . map ( |module| path ( db, module, definition_owner_name ( db, def, edition) , edition) )
816+ let container: Option < Definition > =
817+ def. as_assoc_item ( db) . and_then ( |assoc| match assoc. container ( db) {
818+ AssocItemContainer :: Trait ( trait_) => Some ( trait_. into ( ) ) ,
819+ AssocItemContainer :: Impl ( impl_) => impl_. self_ty ( db) . as_adt ( ) . map ( |adt| adt. into ( ) ) ,
820+ } ) ;
821+ container
822+ . unwrap_or ( * def)
823+ . module ( db)
824+ . map ( |module| path ( db, module, definition_owner_name ( db, def, edition) , edition) )
817825}
818826
819827fn markup ( docs : Option < String > , desc : String , mod_path : Option < String > ) -> Markup {
0 commit comments