Skip to content

Cargo doc spuriously links to random enum variant fields instead of marking links broken #107903

Closed
@tnull

Description

@tnull

Problem

In lightningdevkit/rust-lightning#2027 we stumbled across a bug in cargo doc, as it checking for broken links didn't work for a now renamed field that is also present in another enum variant.

Steps

A minimal example is this, which doesn't fail, but should:

#![deny(broken_intra_doc_links)]

/// Referring to [`TestEnum::Variant1::field_name`]
pub enum TestEnum {
	Variant1 {},
	Variant2 {
		field_name: u64,
	}
}

If TestEnum::Variant1::field_name is present the docs indeed link to the right variant. If it is missing, cargo doc gladly makes the TestEnum::Variant1::field_name link point to TestEnum::Variant2::field_name, without throwing an error.

Possible Solution(s)

No response

Notes

No response

Version

> cargo --version
cargo 1.65.0 (4bc8f24d3 2022-10-20)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-intra-doc-linksArea: Intra-doc links, the ability to link to items in docs by nameC-bugCategory: This is a bug.E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions