Fix intra-doc handling of Self in enum

Fixes #82209
This commit is contained in:
Lucas De Angelis 2021-02-26 22:09:39 +01:00
parent cecdb181ad
commit 5661fe3fa9
2 changed files with 11 additions and 0 deletions

View file

@ -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

View file

@ -0,0 +1,8 @@
#![deny(broken_intra_doc_links)]
pub enum Foo {
Bar {
abc: i32,
/// [Self::Bar::abc]
xyz: i32,
},
}