@@ -327,7 +327,7 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> {
327327 if let Ok ( def) = self . resolve ( path_str, true , & current_item, parent_node) {
328328 def
329329 } else {
330- resolution_failure ( cx, & item. attrs , path_str, & dox, link_range) ;
330+ resolution_failure ( cx, & item, path_str, & dox, link_range) ;
331331 // This could just be a normal link or a broken link
332332 // we could potentially check if something is
333333 // "intra-doc-link-like" and warn in that case.
@@ -338,7 +338,7 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> {
338338 if let Ok ( def) = self . resolve ( path_str, false , & current_item, parent_node) {
339339 def
340340 } else {
341- resolution_failure ( cx, & item. attrs , path_str, & dox, link_range) ;
341+ resolution_failure ( cx, & item, path_str, & dox, link_range) ;
342342 // This could just be a normal link.
343343 continue ;
344344 }
@@ -393,7 +393,7 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> {
393393 {
394394 value_def
395395 } else {
396- resolution_failure ( cx, & item. attrs , path_str, & dox, link_range) ;
396+ resolution_failure ( cx, & item, path_str, & dox, link_range) ;
397397 // this could just be a normal link
398398 continue ;
399399 }
@@ -402,7 +402,7 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> {
402402 if let Some ( def) = macro_resolve ( cx, path_str) {
403403 ( def, None )
404404 } else {
405- resolution_failure ( cx, & item. attrs , path_str, & dox, link_range) ;
405+ resolution_failure ( cx, & item, path_str, & dox, link_range) ;
406406 continue
407407 }
408408 }
@@ -464,11 +464,15 @@ fn macro_resolve(cx: &DocContext<'_>, path_str: &str) -> Option<Def> {
464464/// line containing the failure as a note as well.
465465fn resolution_failure (
466466 cx : & DocContext < ' _ > ,
467- attrs : & Attributes ,
467+ item : & Item ,
468468 path_str : & str ,
469469 dox : & str ,
470470 link_range : Option < Range < usize > > ,
471471) {
472+ if !item. def_id . is_local ( ) { // We don't span warnings for items outside of the current crate.
473+ return ;
474+ }
475+ let attrs = & item. attrs ;
472476 let sp = span_of_attrs ( attrs) ;
473477
474478 let mut diag = cx. tcx . struct_span_lint_hir (
0 commit comments