Skip to content

Rustdoc: #[doc(hidden)] should not apply recursively #81980

Closed
@jyn514

Description

@jyn514

I tried this code:

#[doc(hidden)]
pub mod inner {
  pub struct S;
}
pub use inner::S;

I expected to see this happen: Rustdoc generates docs for S but not inner, since the pub use does not have a doc(hidden) attribute.

Instead, this happened: Rustdoc doesn't generate docs for either (presumably because it applies doc(hidden) recursively).

Additionally, I tried this code:

#[doc(hidden)]
pub use context_api;
mod context_api;

but got a name resolution error:

error[E0255]: the name `context_api` is defined multiple times
   --> src/lib.rs:155:1
    |
153 | pub use context_api;
    |         ----------- previous import of the module `context_api` here
154 | 
155 | mod context_api;
    | ^^^^^^^^^^^^^^^^ `context_api` redefined here
    |
    = note: `context_api` must be defined only once in the type namespace of this module
help: you can use `as` to change the binding name of the import
    |
153 | pub use context_api as other_context_api;
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0365]: `context_api` is private, and cannot be re-exported
   --> src/lib.rs:153:9
    |
153 | pub use context_api;
    |         ^^^^^^^^^^^ re-export of private `context_api`
    |
    = note: consider declaring type or module `context_api` with `pub`

Both of those combined means there's no way to display the docs for only the module and not its items.

Meta

rustdoc --version: rustdoc 1.52.0-nightly (9778068 2021-02-07)

Metadata

Metadata

Assignees

No one assigned

    Labels

    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