mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
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:
commit
b5f5c106c0
@ -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
|
||||
|
11
src/test/rustdoc/intra-doc/issue-82209.rs
Normal file
11
src/test/rustdoc/intra-doc/issue-82209.rs
Normal 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'
|
Loading…
Reference in New Issue
Block a user