rustdoc: pub use
items have docs inlined if impl is private even if use
'd path is a public reexport
#94338
Labels
A-local-reexports
Area: Documentation that has been locally re-exported (i.e., non-cross-crate)
C-bug
Category: This is a bug.
T-rustdoc
Relevant to the rustdoc team, which will review and decide on the PR/issue.
The rustdoc book explains that
pub use
items are documented under "Re-exports" by default when re-exporting a public item, and are inlined by default when re-exporting a private item.Unfortunately, this appears to be implemented today by checking whether the item in its original path is public or private. In particular, it does not check whether the
use
'd path itself is public.For example, if I adapt the code sample from that documentation by introducing a private module with two re-exports:
the generated documentation behaves as though I used
#[doc(inline)]
on the top-level re-export. I can add#[doc(no_inline)]
and it will behave correctly, showing up as a re-export ofbar::Bar
, which itself is inlined. But the default behavior ends up with two separate inlined copies of theBar
trait, one atcrate::Bar
and the other atcrate::bar::Bar
, and there's nothing on the inlined docs that indicates that they're the same item.You can see this today in documentation like bytes which has
bytes::Buf
andbytes::buf::Buf
.There's also some broken behavior in the reverse direction, which is documented in #94336.
Expected behavior
Re-exports should consider the visibility of the re-exported path, not the underlying item. Also see #94336 for a discussion of what happens if the re-exported path is a private re-export of a public item.
Meta
rustdoc --version --verbose
:The text was updated successfully, but these errors were encountered: