diff options
| author | max-heller <max.a.heller@gmail.com> | 2021-01-03 15:34:06 -0500 |
|---|---|---|
| committer | max-heller <max.a.heller@gmail.com> | 2021-01-03 20:38:28 -0500 |
| commit | b4a0ef066d645b430091017203882b6ea39b73a1 (patch) | |
| tree | 33c5e1f4e3672100520e92f7395c3348dadb226f | |
| parent | 80184183ba0a53aa4f491753de9502acd3d6920c (diff) | |
| download | rust-b4a0ef066d645b430091017203882b6ea39b73a1.tar.gz rust-b4a0ef066d645b430091017203882b6ea39b73a1.zip | |
fix issue 80559
| -rw-r--r-- | src/librustdoc/passes/collect_intra_doc_links.rs | 15 | ||||
| -rw-r--r-- | src/test/rustdoc/issue-80559.rs | 4 |
2 files changed, 14 insertions, 5 deletions
diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 0cefbb34791..fd63d5eb5c9 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -394,10 +394,14 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> { ns, impl_, ) - .map(|item| match item.kind { - ty::AssocKind::Fn => "method", - ty::AssocKind::Const => "associatedconstant", - ty::AssocKind::Type => "associatedtype", + .map(|item| { + let kind = item.kind; + self.kind_side_channel.set(Some((kind.as_def_kind(), item.def_id))); + match kind { + ty::AssocKind::Fn => "method", + ty::AssocKind::Const => "associatedconstant", + ty::AssocKind::Type => "associatedtype", + } }) .map(|out| { ( @@ -1143,7 +1147,7 @@ impl LinkCollector<'_, '_> { ); }; match res { - Res::Primitive(_) => match disambiguator { + Res::Primitive(_) if self.kind_side_channel.get().is_none() => match disambiguator { Some(Disambiguator::Primitive | Disambiguator::Namespace(_)) | None => { Some(ItemLink { link: ori_link.link, link_text, did: None, fragment }) } @@ -1152,6 +1156,7 @@ impl LinkCollector<'_, '_> { None } }, + Res::Primitive(_) => Some(ItemLink { link: ori_link, link_text, did: None, fragment }), Res::Def(kind, id) => { debug!("intra-doc link to {} resolved to {:?}", path_str, res); diff --git a/src/test/rustdoc/issue-80559.rs b/src/test/rustdoc/issue-80559.rs new file mode 100644 index 00000000000..34905c48653 --- /dev/null +++ b/src/test/rustdoc/issue-80559.rs @@ -0,0 +1,4 @@ +#![deny(broken_intra_doc_links)] +// Should link to https://doc.rust-lang.org/nightly/std/primitive.str.html#method.trim +// and not suggest prefixing with `prim@` +//! [str::trim()] |
