Skip to content

rustdoc: nested items should not be documented with --document-private-items #110422

Description

@GuillaumeGomez

If we run rustdoc with the --document-private-items option on this code:

pub fn foo() {
    fn bar() {}
}

Both foo and bar are documented, but bar not being accessible outside of foo, it shouldn't be documented.

Activity

  1. added
    T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
    C-bugCategory: This is a bug.
    on Apr 16, 2023
  2. compiler-errors commented on Apr 16, 2023

    @compiler-errors
    Contributor

    @GuillaumeGomez probably knows this, but for others seeing this issue, I think it's probably due to #104889 (which was reverted in #107083, and later re-applied in #107000 (comment)).

    It has to do with the fact that we're using a HIR visitor now, so we're visiting nested items unconditionally.

  3. GuillaumeGomez commented on Apr 16, 2023

    @GuillaumeGomez
    MemberAuthor

    Yes I know where it's coming from. 😄

    I was just thinking today that since we were going through the whole HIR without checking whether or not we were in a block, all elements inside the block could be visible. Tested and... 😨

    Should be pretty easy to fix.

  4. compiler-errors commented on Apr 16, 2023

    @compiler-errors
    Contributor

    For reference, I put up serde-rs/serde#2426 because this was causing documentation to become really verbose with serde + --document-private-items. If you fix this such that we no longer document those items, we could probably revert that PR.

  5. GuillaumeGomez commented on Apr 16, 2023

    @GuillaumeGomez
    MemberAuthor

    Indeed. Don't hesitate to come to me if you have such issues with rustdoc. Such problems should definitely not go unnoticed.

  6. compiler-errors commented on Apr 16, 2023

    @compiler-errors
    Contributor

    Don't hesitate to come to me if you have such issues with rustdoc.

    The thing is, it was not particularly clear from the PRs whether this was intentional or not.

  7. GuillaumeGomez commented on Apr 16, 2023

    @GuillaumeGomez
    MemberAuthor

    Unfortunately it wasn't. The goal was to retrieve the missing impl blocks. But if anything isn't clear, don't hesitate to ask too. 😉

  8. added a commit that references this issue on Apr 18, 2023
    d646891
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

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