@@ -172,34 +172,50 @@ impl<'ra> EarlyDocLinkResolver<'_, 'ra> {
172172    } 
173173
174174    fn  resolve_doc_links_extern_impl ( & mut  self ,  def_id :  DefId ,  is_inherent :  bool )  { 
175-         self . resolve_doc_links_extern_outer ( def_id,  def_id) ; 
175+         self . resolve_doc_links_extern_outer_fixme ( def_id,  def_id) ; 
176176        let  assoc_item_def_ids = Vec :: from_iter ( 
177177            self . resolver . cstore ( ) . associated_item_def_ids_untracked ( def_id,  self . sess ) , 
178178        ) ; 
179179        for  assoc_def_id in  assoc_item_def_ids { 
180180            if  !is_inherent || self . resolver . cstore ( ) . visibility_untracked ( assoc_def_id) . is_public ( ) 
181181            { 
182-                 self . resolve_doc_links_extern_outer ( assoc_def_id,  def_id) ; 
182+                 self . resolve_doc_links_extern_outer_fixme ( assoc_def_id,  def_id) ; 
183183            } 
184184        } 
185185    } 
186186
187-     fn  resolve_doc_links_extern_outer ( & mut  self ,  def_id :  DefId ,  scope_id :  DefId )  { 
187+     // FIXME: replace all uses with `resolve_doc_links_extern_outer` to actually resolve links, not 
188+     // just add traits in scope. This may be expensive and require benchmarking and optimization. 
189+     fn  resolve_doc_links_extern_outer_fixme ( & mut  self ,  def_id :  DefId ,  scope_id :  DefId )  { 
188190        if  !self . resolver . cstore ( ) . may_have_doc_links_untracked ( def_id)  { 
189191            return ; 
190192        } 
191-         // FIXME: actually resolve links, not just add traits in scope. 
192193        if  let  Some ( parent_id)  = self . resolver . opt_parent ( scope_id)  { 
193194            self . add_traits_in_scope ( parent_id) ; 
194195        } 
195196    } 
196197
198+     fn  resolve_doc_links_extern_outer ( & mut  self ,  def_id :  DefId ,  scope_id :  DefId )  { 
199+         if  !self . resolver . cstore ( ) . may_have_doc_links_untracked ( def_id)  { 
200+             return ; 
201+         } 
202+         let  attrs = Vec :: from_iter ( self . resolver . cstore ( ) . item_attrs_untracked ( def_id,  self . sess ) ) ; 
203+         let  parent_scope = ParentScope :: module ( 
204+             self . resolver . get_nearest_non_block_module ( 
205+                 self . resolver . opt_parent ( scope_id) . unwrap_or ( scope_id) , 
206+             ) , 
207+             self . resolver , 
208+         ) ; 
209+         self . resolve_doc_links ( doc_attrs ( attrs. iter ( ) ) ,  parent_scope) ; 
210+     } 
211+ 
197212    fn  resolve_doc_links_extern_inner ( & mut  self ,  def_id :  DefId )  { 
198213        if  !self . resolver . cstore ( ) . may_have_doc_links_untracked ( def_id)  { 
199214            return ; 
200215        } 
201-         // FIXME: actually resolve links, not just add traits in scope. 
202-         self . add_traits_in_scope ( def_id) ; 
216+         let  attrs = Vec :: from_iter ( self . resolver . cstore ( ) . item_attrs_untracked ( def_id,  self . sess ) ) ; 
217+         let  parent_scope = ParentScope :: module ( self . resolver . expect_module ( def_id) ,  self . resolver ) ; 
218+         self . resolve_doc_links ( doc_attrs ( attrs. iter ( ) ) ,  parent_scope) ; 
203219    } 
204220
205221    fn  resolve_doc_links_local ( & mut  self ,  attrs :  & [ ast:: Attribute ] )  { 
@@ -253,9 +269,16 @@ impl<'ra> EarlyDocLinkResolver<'_, 'ra> {
253269                        } 
254270                    } 
255271
256-                     // FIXME: Resolve all prefixes for type-relative resolution or for diagnostics. 
257-                     if  ( need_assoc || !any_resolved)  && pinfo. path_str . contains ( "::" )  { 
258-                         need_traits_in_scope = true ; 
272+                     // Resolve all prefixes for type-relative resolution or for diagnostics. 
273+                     if  need_assoc || !any_resolved { 
274+                         let  mut  path = & pinfo. path_str [ ..] ; 
275+                         while  let  Some ( idx)  = path. rfind ( "::" )  { 
276+                             path = & path[ ..idx] ; 
277+                             need_traits_in_scope = true ; 
278+                             for  ns in  [ TypeNS ,  ValueNS ,  MacroNS ]  { 
279+                                 self . resolve_and_cache ( path,  ns,  & parent_scope) ; 
280+                             } 
281+                         } 
259282                    } 
260283                } 
261284            } 
0 commit comments