Skip to content

Commit b5f5c10

Browse files
authored
Rollup merge of #82563 - lucas-deangelis:issue-82209-fix, r=jyn514
Fix intra-doc handling of `Self` in enum Fixes #82209
2 parents b1113ab + 5835f6d commit b5f5c10

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/librustdoc/passes/collect_intra_doc_links.rs

+8
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,14 @@ 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 an enum variant
842+
} else if (matches!(self.cx.tcx.def_kind(item.def_id), DefKind::Field)
843+
&& matches!(
844+
self.cx.tcx.def_kind(self.cx.tcx.parent(item.def_id).unwrap()),
845+
DefKind::Variant
846+
))
847+
{
848+
self.cx.tcx.parent(item.def_id).and_then(|item_id| self.cx.tcx.parent(item_id))
841849
} else if matches!(
842850
self.cx.tcx.def_kind(item.def_id),
843851
DefKind::AssocConst
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#![crate_name = "foo"]
2+
#![deny(broken_intra_doc_links)]
3+
pub enum Foo {
4+
Bar {
5+
abc: i32,
6+
/// [Self::Bar::abc]
7+
xyz: i32,
8+
},
9+
}
10+
11+
// @has foo/enum.Foo.html '//a/@href' '../foo/enum.Foo.html#variant.Bar.field.abc'

0 commit comments

Comments
 (0)