@@ -327,7 +327,7 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> {
327
327
if let Ok ( def) = self . resolve ( path_str, true , & current_item, parent_node) {
328
328
def
329
329
} else {
330
- resolution_failure ( cx, & item. attrs , path_str, & dox, link_range) ;
330
+ resolution_failure ( cx, & item, path_str, & dox, link_range) ;
331
331
// This could just be a normal link or a broken link
332
332
// we could potentially check if something is
333
333
// "intra-doc-link-like" and warn in that case.
@@ -338,7 +338,7 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> {
338
338
if let Ok ( def) = self . resolve ( path_str, false , & current_item, parent_node) {
339
339
def
340
340
} else {
341
- resolution_failure ( cx, & item. attrs , path_str, & dox, link_range) ;
341
+ resolution_failure ( cx, & item, path_str, & dox, link_range) ;
342
342
// This could just be a normal link.
343
343
continue ;
344
344
}
@@ -393,7 +393,7 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> {
393
393
{
394
394
value_def
395
395
} else {
396
- resolution_failure ( cx, & item. attrs , path_str, & dox, link_range) ;
396
+ resolution_failure ( cx, & item, path_str, & dox, link_range) ;
397
397
// this could just be a normal link
398
398
continue ;
399
399
}
@@ -402,7 +402,7 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> {
402
402
if let Some ( def) = macro_resolve ( cx, path_str) {
403
403
( def, None )
404
404
} else {
405
- resolution_failure ( cx, & item. attrs , path_str, & dox, link_range) ;
405
+ resolution_failure ( cx, & item, path_str, & dox, link_range) ;
406
406
continue
407
407
}
408
408
}
@@ -464,11 +464,15 @@ fn macro_resolve(cx: &DocContext<'_>, path_str: &str) -> Option<Def> {
464
464
/// line containing the failure as a note as well.
465
465
fn resolution_failure (
466
466
cx : & DocContext < ' _ > ,
467
- attrs : & Attributes ,
467
+ item : & Item ,
468
468
path_str : & str ,
469
469
dox : & str ,
470
470
link_range : Option < Range < usize > > ,
471
471
) {
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 ;
472
476
let sp = span_of_attrs ( attrs) ;
473
477
474
478
let mut diag = cx. tcx . struct_span_lint_hir (
0 commit comments