@@ -172,34 +172,50 @@ impl<'ra> EarlyDocLinkResolver<'_, 'ra> {
172
172
}
173
173
174
174
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) ;
176
176
let assoc_item_def_ids = Vec :: from_iter (
177
177
self . resolver . cstore ( ) . associated_item_def_ids_untracked ( def_id, self . sess ) ,
178
178
) ;
179
179
for assoc_def_id in assoc_item_def_ids {
180
180
if !is_inherent || self . resolver . cstore ( ) . visibility_untracked ( assoc_def_id) . is_public ( )
181
181
{
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) ;
183
183
}
184
184
}
185
185
}
186
186
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 ) {
188
190
if !self . resolver . cstore ( ) . may_have_doc_links_untracked ( def_id) {
189
191
return ;
190
192
}
191
- // FIXME: actually resolve links, not just add traits in scope.
192
193
if let Some ( parent_id) = self . resolver . opt_parent ( scope_id) {
193
194
self . add_traits_in_scope ( parent_id) ;
194
195
}
195
196
}
196
197
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
+
197
212
fn resolve_doc_links_extern_inner ( & mut self , def_id : DefId ) {
198
213
if !self . resolver . cstore ( ) . may_have_doc_links_untracked ( def_id) {
199
214
return ;
200
215
}
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) ;
203
219
}
204
220
205
221
fn resolve_doc_links_local ( & mut self , attrs : & [ ast:: Attribute ] ) {
@@ -253,9 +269,16 @@ impl<'ra> EarlyDocLinkResolver<'_, 'ra> {
253
269
}
254
270
}
255
271
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
+ }
259
282
}
260
283
}
261
284
}
0 commit comments