Skip to content

Rustdoc links are broken when glob reexporting items from a doc(hidden) module in another crate. #127445

Open
@kpreid

Description

@kpreid

Rustdoc silently (no warnings) generates broken links when the item being linked to is glob-reexported from a module with the #[doc(hidden)] attribute that is from a different crate. This happens regardless of which crate the link is written in.

To reproduce, run cargo doc on two crates foo and bar with the following contents:

// foo/src/lib.rs
#[doc(hidden)]
pub mod hidden_module {
    /// [`FooOne`] [`FooTwo`] [`FooThree`]
    pub struct FooOne;
    pub struct FooTwo;
    pub struct FooThree;
}
// bar/src/lib.rs
pub use foo::hidden_module::{FooTwo, *};

/// [`FooOne`] [`FooTwo`] [`FooThree`]
pub struct Bar;

The links to FooOne and FooThree are broken as if they were unknown names, even though rustdoc emits no warnings about them like it usually does for broken links, and the documentation is otherwise functional.

Meta

rustc --version --verbose:

rustc 1.79.0 (129f3b996 2024-06-10)
binary: rustc
commit-hash: 129f3b9964af4d4a709d1383930ade12dfe7c081
commit-date: 2024-06-10
host: x86_64-apple-darwin
release: 1.79.0
LLVM version: 18.1.7

Also reproduces on nightly.

@rustbot label +T-rustdoc

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-cross-crate-reexportsArea: Documentation that has been re-exported from a different crateA-intra-doc-linksArea: Intra-doc links, the ability to link to items in docs by nameA-rustdoc-uiArea: Rustdoc UI (generated HTML)C-bugCategory: This is a bug.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