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] Documentation not being generated for doc(inline)ed re-export of a doc(hidden) item in another crate #123435

Closed
AhmadAlHallak opened this issue Apr 3, 2024 · 2 comments · Fixed by #123459
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

@AhmadAlHallak
Copy link

AhmadAlHallak commented Apr 3, 2024

Suppose we have crates a, and b (crate b being a nested crate within crate a), and we have the following in a/b/src/lib.rs:

#[doc(hidden)]
pub struct HiddenInCrateB;

and then in a/src/lib.rs:

/// Docs that I think should be generated for an inlined re-export of `b::DocHiddenInB` but are not
#[doc(inline)]
pub use b::HiddenInCrateB;

mod c {
    #[doc(hidden)]
    pub struct HiddenInModuleC;
}
/// Docs that are generated for an inlined re-export of `c::HiddenInModuleC`
#[doc(inline)]
pub use c::HiddenInModuleC;

and then run cargo doc and open the generated documentation for crate a we would see an entry HiddenInModuleC but not for HiddenInCrateB

I expected documentation to be generated for both HiddenInModuleC and HiddenInCrateB, or alternatively no docs being generated for either.

Meta

rustc --version --verbose:

rustc 1.77.1 (7cf61ebde 2024-03-27)
binary: rustc
commit-hash: 7cf61ebde7b22796c69757901dd346d0fe70bd97
commit-date: 2024-03-27
host: x86_64-pc-windows-msvc
release: 1.77.1
LLVM version: 17.0.6

Tasks

Preview Give feedback
No tasks being tracked yet.
@AhmadAlHallak AhmadAlHallak added the C-bug Category: This is a bug. label Apr 3, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 3, 2024
@AhmadAlHallak
Copy link
Author

@GuillaumeGomez is this intended behavior?

@GuillaumeGomez GuillaumeGomez added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Apr 4, 2024
@GuillaumeGomez
Copy link
Member

Sounds like a bug. Taking a look.

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Apr 4, 2024
@bors bors closed this as completed in bcdc281 Apr 11, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Apr 11, 2024
Rollup merge of rust-lang#123459 - GuillaumeGomez:fix-123435, r=notriddle

Correctly handle inlining of doc hidden foreign items

Fixes rust-lang#123435.

In case a foreign item has doc(hidden) attribute, we simply merged its attributes with the re-export's, making it being removed once in the `strip_hidden` pass.

The solution was to use the same as for local reexported items: merge attributes, but not some of them (like `doc(hidden)`).

I originally checked if we could simply update `Item::is_doc_hidden` method to use `self.inline_stmt_id.is_some_and(|def_id| tcx.is_doc_hidden(def_id))` but unfortunately, it added (local) items that shouldn't be inlined. At least it unifies local and foreign items inlining, which I think is the best course of action here.

r? `@notriddle`
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.

3 participants