Skip to content
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

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

Closed
GuillaumeGomez opened this issue Apr 16, 2023 · 6 comments · Fixed by #110450
Closed

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

GuillaumeGomez opened this issue Apr 16, 2023 · 6 comments · Fixed by #110450
Assignees
Labels
C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@GuillaumeGomez
Copy link
Member

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.

@GuillaumeGomez GuillaumeGomez added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Apr 16, 2023
@GuillaumeGomez GuillaumeGomez self-assigned this Apr 16, 2023
@compiler-errors
Copy link
Member

@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.

@GuillaumeGomez
Copy link
Member Author

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.

@compiler-errors
Copy link
Member

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.

@GuillaumeGomez
Copy link
Member Author

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

@compiler-errors
Copy link
Member

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.

@GuillaumeGomez
Copy link
Member Author

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. 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

2 participants