Skip to content

Commit

Permalink
Rollup merge of rust-lang#82563 - lucas-deangelis:issue-82209-fix, r=…
Browse files Browse the repository at this point in the history
…jyn514

Fix intra-doc handling of `Self` in enum

Fixes rust-lang#82209
  • Loading branch information
Dylan-DPC committed Feb 27, 2021
2 parents b1113ab + 5835f6d commit b5f5c10
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/librustdoc/passes/collect_intra_doc_links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,14 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> {
debug!("looking for the `Self` type");
let self_id = if item.is_fake() {
None
// Checking if the item is a field in an enum variant
} 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
))
{
self.cx.tcx.parent(item.def_id).and_then(|item_id| self.cx.tcx.parent(item_id))
} else if matches!(
self.cx.tcx.def_kind(item.def_id),
DefKind::AssocConst
Expand Down
11 changes: 11 additions & 0 deletions src/test/rustdoc/intra-doc/issue-82209.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#![crate_name = "foo"]
#![deny(broken_intra_doc_links)]
pub enum Foo {
Bar {
abc: i32,
/// [Self::Bar::abc]
xyz: i32,
},
}

// @has foo/enum.Foo.html '//a/@href' '../foo/enum.Foo.html#variant.Bar.field.abc'

0 comments on commit b5f5c10

Please sign in to comment.