Skip to content

Commit b4a0ef0

Browse files
committed
fix issue 80559
1 parent 8018418 commit b4a0ef0

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/librustdoc/passes/collect_intra_doc_links.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -394,10 +394,14 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
394394
ns,
395395
impl_,
396396
)
397-
.map(|item| match item.kind {
398-
ty::AssocKind::Fn => "method",
399-
ty::AssocKind::Const => "associatedconstant",
400-
ty::AssocKind::Type => "associatedtype",
397+
.map(|item| {
398+
let kind = item.kind;
399+
self.kind_side_channel.set(Some((kind.as_def_kind(), item.def_id)));
400+
match kind {
401+
ty::AssocKind::Fn => "method",
402+
ty::AssocKind::Const => "associatedconstant",
403+
ty::AssocKind::Type => "associatedtype",
404+
}
401405
})
402406
.map(|out| {
403407
(
@@ -1143,7 +1147,7 @@ impl LinkCollector<'_, '_> {
11431147
);
11441148
};
11451149
match res {
1146-
Res::Primitive(_) => match disambiguator {
1150+
Res::Primitive(_) if self.kind_side_channel.get().is_none() => match disambiguator {
11471151
Some(Disambiguator::Primitive | Disambiguator::Namespace(_)) | None => {
11481152
Some(ItemLink { link: ori_link.link, link_text, did: None, fragment })
11491153
}
@@ -1152,6 +1156,7 @@ impl LinkCollector<'_, '_> {
11521156
None
11531157
}
11541158
},
1159+
Res::Primitive(_) => Some(ItemLink { link: ori_link, link_text, did: None, fragment }),
11551160
Res::Def(kind, id) => {
11561161
debug!("intra-doc link to {} resolved to {:?}", path_str, res);
11571162

src/test/rustdoc/issue-80559.rs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#![deny(broken_intra_doc_links)]
2+
// Should link to https://doc.rust-lang.org/nightly/std/primitive.str.html#method.trim
3+
// and not suggest prefixing with `prim@`
4+
//! [str::trim()]

0 commit comments

Comments
 (0)