Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 a variant in an enum
Comment thread
lucas-deangelis marked this conversation as resolved.
Outdated
} 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]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also test that this generates the right link? There's instructions at https://rustc-dev-guide.rust-lang.org/rustdoc-internals.html#dotting-is-and-crossing-ts and examples in the other files in this directory.

Please also move this to rustdoc/intra-doc, with the rest of the intra-doc link tests.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a test for the generation of the link. I used a #![crate_name = "foo"]at the beginning since I couldn't get it to work with issue-82209 as the name of the file. Is the repetition of "foo" okay?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's fine. Fyi the way to do it with dashes is to change them to underscores in the filename, but this works too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation.

xyz: i32,
},
}