Skip to content

Commit 5661fe3

Browse files
Fix intra-doc handling of Self in enum
Fixes #82209
1 parent cecdb18 commit 5661fe3

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/librustdoc/passes/collect_intra_doc_links.rs

+3
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,9 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> {
838838
debug!("looking for the `Self` type");
839839
let self_id = if item.is_fake() {
840840
None
841+
// Checking if the item is a field in a variant in an enum
842+
} else if (matches!(self.cx.tcx.def_kind(item.def_id), DefKind::Field) && matches!(self.cx.tcx.def_kind(self.cx.tcx.parent(item.def_id).unwrap()), DefKind::Variant)) {
843+
self.cx.tcx.parent(item.def_id).and_then(|item_id| self.cx.tcx.parent(item_id))
841844
} else if matches!(
842845
self.cx.tcx.def_kind(item.def_id),
843846
DefKind::AssocConst

src/test/rustdoc/issue-82209.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#![deny(broken_intra_doc_links)]
2+
pub enum Foo {
3+
Bar {
4+
abc: i32,
5+
/// [Self::Bar::abc]
6+
xyz: i32,
7+
},
8+
}

0 commit comments

Comments
 (0)