Skip to content

Commit

Permalink
Fix intra-doc handling of Self in enum
Browse files Browse the repository at this point in the history
Fixes #82209
  • Loading branch information
lucas-deangelis committed Feb 26, 2021
1 parent cecdb18 commit 5661fe3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 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,9 @@ 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 a variant in an enum
} 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
8 changes: 8 additions & 0 deletions src/test/rustdoc/issue-82209.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#![deny(broken_intra_doc_links)]
pub enum Foo {
Bar {
abc: i32,
/// [Self::Bar::abc]
xyz: i32,
},
}

0 comments on commit 5661fe3

Please sign in to comment.