Skip to content

rustdoc: Inline code in links in first paragraph of doc of trait implementation not clickable #140857

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
SpecificProtagonist opened this issue May 9, 2025 · 0 comments · May be fixed by #140868
Labels
A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@SpecificProtagonist
Copy link
Contributor

SpecificProtagonist commented May 9, 2025

Any inline code in a link in the first paragraph of the documentation of an implementation of a trait with at least one item isn't clickable.

MRE:

struct Type;

trait Trait {
    const ITEM: () = ();
}

/// [`i32`]
///
/// [`i32`]
impl Trait for Type {}

I expected to see this happen:

In the documentation generated by cargo doc, both links should be clickable.

Instead, this happened:

Unless JS is disabled, clicking on the top link does nothing.

Meta

rustc --version:

rustc 1.88.0-nightly (d5b4c2e4f 2025-04-02)

The cause seems to be this event listener, which is added to the impl's summary and doesn't account for the fact that inline code is allowed inside Markdown links:

onEachLazy(document.querySelectorAll(".toggle > summary:not(.hideme)"), el => {
    // @ts-expect-error
    el.addEventListener("click", e => {
        if (e.target.tagName !== "SUMMARY" && e.target.tagName !== "A") {
            e.preventDefault();
        }
    });
});
@SpecificProtagonist SpecificProtagonist added the C-bug Category: This is a bug. label May 9, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 9, 2025
@fmease fmease added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels May 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants