Rollup merge of #82563 - lucas-deangelis:issue-82209-fix, r=jyn514

Fix intra-doc handling of `Self` in enum

Fixes #82209
This commit is contained in:
Dylan DPC 2021-02-27 21:56:22 +01:00 committed by GitHub
commit b5f5c106c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions

View File

@ -838,6 +838,14 @@ fn fold_item(&mut self, mut item: Item) -> Option<Item> {
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

View File

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