From 8ed7d936f8780a857a981676899ab24660529e7b Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Mon, 5 Apr 2021 05:01:15 -0400 Subject: [PATCH] Take `DiagnosticInfo` in `resolution_failure` --- .../passes/collect_intra_doc_links.rs | 36 ++++--------------- 1 file changed, 6 insertions(+), 30 deletions(-) diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 09823d4b0594..496c2f57c3fc 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -1023,11 +1023,9 @@ impl LinkCollector<'_, '_> { debug!("attempting to resolve item without parent module: {}", path_str); resolution_failure( self, - &item, + diag_info, path_str, disambiguator, - dox, - ori_link.range, smallvec![ResolutionFailure::NoParentItem], ); return None; @@ -1073,11 +1071,9 @@ impl LinkCollector<'_, '_> { debug!("link has malformed generics: {}", path_str); resolution_failure( self, - &item, + diag_info, path_str, disambiguator, - dox, - ori_link.range, smallvec![err_kind], ); return None; @@ -1337,15 +1333,7 @@ impl LinkCollector<'_, '_> { } } } - resolution_failure( - self, - diag.item, - path_str, - disambiguator, - diag.dox, - diag.link_range, - smallvec![kind], - ); + resolution_failure(self, diag, path_str, disambiguator, smallvec![kind]); // This could just be a normal link or a broken link // we could potentially check if something is // "intra-doc-link-like" and warn in that case. @@ -1406,11 +1394,9 @@ impl LinkCollector<'_, '_> { if len == 0 { resolution_failure( self, - diag.item, + diag, path_str, disambiguator, - diag.dox, - diag.link_range, candidates.into_iter().filter_map(|res| res.err()).collect(), ); // this could just be a normal link @@ -1452,15 +1438,7 @@ impl LinkCollector<'_, '_> { break; } } - resolution_failure( - self, - diag.item, - path_str, - disambiguator, - diag.dox, - diag.link_range, - smallvec![kind], - ); + resolution_failure(self, diag, path_str, disambiguator, smallvec![kind]); None } } @@ -1750,11 +1728,9 @@ fn report_diagnostic( /// `std::io::Error::x`, this will resolve `std::io::Error`. fn resolution_failure( collector: &mut LinkCollector<'_, '_>, - item: &Item, + DiagnosticInfo { item, ori_link: _, dox, link_range }: DiagnosticInfo<'_>, path_str: &str, disambiguator: Option, - dox: &str, - link_range: Range, kinds: SmallVec<[ResolutionFailure<'_>; 3]>, ) { let tcx = collector.cx.tcx;