summaryrefslogtreecommitdiffstats
path: root/src/librustdoc/passes/collect_intra_doc_links.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/librustdoc/passes/collect_intra_doc_links.rs')
-rw-r--r--src/librustdoc/passes/collect_intra_doc_links.rs48
1 files changed, 25 insertions, 23 deletions
diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs
index 7b0a7a90d..d216305e6 100644
--- a/src/librustdoc/passes/collect_intra_doc_links.rs
+++ b/src/librustdoc/passes/collect_intra_doc_links.rs
@@ -16,7 +16,9 @@ use rustc_hir::Mutability;
use rustc_middle::ty::{Ty, TyCtxt};
use rustc_middle::{bug, span_bug, ty};
use rustc_resolve::rustdoc::{has_primitive_or_keyword_docs, prepare_to_doc_link_resolution};
-use rustc_resolve::rustdoc::{strip_generics_from_path, MalformedGenerics};
+use rustc_resolve::rustdoc::{
+ source_span_for_markdown_range, strip_generics_from_path, MalformedGenerics,
+};
use rustc_session::lint::Lint;
use rustc_span::hygiene::MacroKind;
use rustc_span::symbol::{sym, Ident, Symbol};
@@ -520,8 +522,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
ty::Alias(..)
| ty::Closure(..)
| ty::Generator(..)
- | ty::GeneratorWitness(_)
- | ty::GeneratorWitnessMIR(..)
+ | ty::GeneratorWitness(..)
| ty::Dynamic(..)
| ty::Param(_)
| ty::Bound(..)
@@ -592,7 +593,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
.unwrap_or(Vec::new())
}
}
- Res::Def(DefKind::TyAlias { .. }, did) => {
+ Res::Def(DefKind::TyAlias, did) => {
// Resolve the link on the type the alias points to.
// FIXME: if the associated item is defined directly on the type alias,
// it will show up on its documentation page, we should link there instead.
@@ -1211,11 +1212,11 @@ impl LinkCollector<'_, '_> {
ori_link: &MarkdownLinkRange,
item: &Item,
) {
- let span = super::source_span_for_markdown_range(
+ let span = source_span_for_markdown_range(
self.cx.tcx,
dox,
ori_link.inner_range(),
- &item.attrs,
+ &item.attrs.doc_strings,
)
.unwrap_or_else(|| item.attr_span(self.cx.tcx));
rustc_session::parse::feature_err(
@@ -1702,26 +1703,27 @@ fn report_diagnostic(
let (span, link_range) = match link_range {
MarkdownLinkRange::Destination(md_range) => {
let mut md_range = md_range.clone();
- let sp = super::source_span_for_markdown_range(tcx, dox, &md_range, &item.attrs)
- .map(|mut sp| {
- while dox.as_bytes().get(md_range.start) == Some(&b' ')
- || dox.as_bytes().get(md_range.start) == Some(&b'`')
- {
- md_range.start += 1;
- sp = sp.with_lo(sp.lo() + BytePos(1));
- }
- while dox.as_bytes().get(md_range.end - 1) == Some(&b' ')
- || dox.as_bytes().get(md_range.end - 1) == Some(&b'`')
- {
- md_range.end -= 1;
- sp = sp.with_hi(sp.hi() - BytePos(1));
- }
- sp
- });
+ let sp =
+ source_span_for_markdown_range(tcx, dox, &md_range, &item.attrs.doc_strings)
+ .map(|mut sp| {
+ while dox.as_bytes().get(md_range.start) == Some(&b' ')
+ || dox.as_bytes().get(md_range.start) == Some(&b'`')
+ {
+ md_range.start += 1;
+ sp = sp.with_lo(sp.lo() + BytePos(1));
+ }
+ while dox.as_bytes().get(md_range.end - 1) == Some(&b' ')
+ || dox.as_bytes().get(md_range.end - 1) == Some(&b'`')
+ {
+ md_range.end -= 1;
+ sp = sp.with_hi(sp.hi() - BytePos(1));
+ }
+ sp
+ });
(sp, MarkdownLinkRange::Destination(md_range))
}
MarkdownLinkRange::WholeLink(md_range) => (
- super::source_span_for_markdown_range(tcx, dox, &md_range, &item.attrs),
+ source_span_for_markdown_range(tcx, dox, &md_range, &item.attrs.doc_strings),
link_range.clone(),
),
};