diff options
Diffstat (limited to '')
-rw-r--r-- | src/librustdoc/passes/collect_intra_doc_links.rs | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 7d7a63c53..b2a41bfa4 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -223,6 +223,9 @@ enum MalformedGenerics { #[derive(Clone, Debug, Hash, PartialEq, Eq)] pub(crate) enum UrlFragment { Item(DefId), + /// A part of a page that isn't a rust item. + /// + /// Eg: `[Vector Examples](std::vec::Vec#examples)` UserWritten(String), } @@ -477,7 +480,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> { // If there's no `::`, it's not an associated item. // So we can be sure that `rustc_resolve` was accurate when it said it wasn't resolved. .ok_or_else(|| { - debug!("found no `::`, assumming {} was correctly not in scope", item_name); + debug!("found no `::`, assuming {} was correctly not in scope", item_name); UnresolvedPath { item_id, module_id, @@ -750,7 +753,7 @@ fn resolve_associated_trait_item<'a>( /// /// This is just a wrapper around [`TyCtxt::impl_item_implementor_ids()`] and /// [`TyCtxt::associated_item()`] (with some helpful logging added). -#[instrument(level = "debug", skip(tcx))] +#[instrument(level = "debug", skip(tcx), ret)] fn trait_assoc_to_impl_assoc_item<'tcx>( tcx: TyCtxt<'tcx>, impl_id: DefId, @@ -760,9 +763,7 @@ fn trait_assoc_to_impl_assoc_item<'tcx>( debug!(?trait_to_impl_assoc_map); let impl_assoc_id = *trait_to_impl_assoc_map.get(&trait_assoc_id)?; debug!(?impl_assoc_id); - let impl_assoc = tcx.associated_item(impl_assoc_id); - debug!(?impl_assoc); - Some(impl_assoc) + Some(tcx.associated_item(impl_assoc_id)) } /// Given a type, return all trait impls in scope in `module` for that type. @@ -1129,7 +1130,7 @@ impl LinkCollector<'_, '_> { Some(ItemLink { link: ori_link.link.clone(), link_text: link_text.clone(), - did: res.def_id(self.cx.tcx), + page_id: res.def_id(self.cx.tcx), fragment, }) } @@ -1148,11 +1149,12 @@ impl LinkCollector<'_, '_> { item, &diag_info, )?; - let id = clean::register_res(self.cx, rustc_hir::def::Res::Def(kind, id)); + + let page_id = clean::register_res(self.cx, rustc_hir::def::Res::Def(kind, id)); Some(ItemLink { link: ori_link.link.clone(), link_text: link_text.clone(), - did: id, + page_id, fragment, }) } @@ -1256,7 +1258,7 @@ impl LinkCollector<'_, '_> { &mut self, key: ResolutionInfo, diag: DiagnosticInfo<'_>, - // If errors are cached then they are only reported on first ocurrence + // If errors are cached then they are only reported on first occurrence // which we want in some cases but not in others. cache_errors: bool, ) -> Option<(Res, Option<UrlFragment>)> { @@ -1807,8 +1809,8 @@ fn resolution_failure( } return; } - Trait | TyAlias | ForeignTy | OpaqueTy | TraitAlias | TyParam - | Static(_) => "associated item", + Trait | TyAlias | ForeignTy | OpaqueTy | ImplTraitPlaceholder + | TraitAlias | TyParam | Static(_) => "associated item", Impl | GlobalAsm => unreachable!("not a path"), } } else { @@ -1893,7 +1895,7 @@ fn disambiguator_error( diag_info.link_range = disambiguator_range; report_diagnostic(cx.tcx, BROKEN_INTRA_DOC_LINKS, msg, &diag_info, |diag, _sp| { let msg = format!( - "see {}/rustdoc/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators", + "see {}/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators", crate::DOC_RUST_LANG_ORG_CHANNEL ); diag.note(&msg); |