Skip to content

rustdoc: Inconsistant decision to include impl with docs but no visible items #111564

Open

Description

@aDotInTheVoid

Since #90905, rustdoc has impl blocks with docs but no items: But it's logic doesn't make (user facing) sense

pub struct Foo;

/// 1. Empty
impl Foo {}

/// 2. Private
impl Foo {
    fn private() {}
}

/// 3. Public
impl Foo {
    pub fn public() {}
}

/// 4. Public Hidden
impl Foo {
    #[doc(hidden)]
    fn public_hidden() {}
}

/// 5. Private Hidden
impl Foo {
    #[doc(hidden)]
    fn priviate_hidden() {}
}

Running this code across various flag's gets us:

Header --document-private-items --document-hidden-items --document-private-items --document-hidden-items
Empty ✔️ ✔️ ✔️ ✔️
Private ❌ ✔️ ✔️ ✔️
Public ✔️ ✔️ ✔️ ✔️
Public Hidden ✔️ ✔️ ✔️ ✔️
Private Hidden ✔️ ✔️ ✔️ ✔️

It doesn't make sense that adding #[doc(hidden)] to a private function makes it's block visible, or that running --document-hidden-items makes a block with only private functions visible. I'm not sure what the exact behavior should be here

Activity

  1. added
    T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
    on May 14, 2023
  2. GuillaumeGomez commented on May 17, 2023

    @GuillaumeGomez
    Member

    In the code, the comment says:

    Impl blocks can be skipped if they are: empty; not a trait impl; and have no
    documentation.

    There is one special case: if the impl block contains only private items.

    The logic makes sense to me: impl blocks with only private items should very likely not be visible to readers. The question here I think should be more "should we do the same with impls containing only hidden items?". What do you think?

  3. added a commit that references this issue on May 17, 2023
  4. lolbinarycat commented on Jan 19, 2025

    @lolbinarycat
    Contributor

    @GuillaumeGomez the "private hidden" case definitely seems like a bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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