rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.14k stars 12.69k forks source link

rustdoc leaks private types in Implementations on Foreign Types #127947

Open zacknewman opened 3 months ago

zacknewman commented 3 months ago

Problem

When a pub trait is implemented on a constructed type—not counting references if those are "type constructors"—that was constructed based on a private type, it is shown in the documentation. Ideally it would not do this as I like private types to not leak into my documentation. The type constructor has to be pub of course (e.g., a slice).

Steps

/// `Foo`.
pub trait Foo {}
/// `Fizz`.
struct Fizz;
impl Foo for [Fizz] {}

cargo doc --open will generate documentation that shows the trait Foo. When clicking on it, it will show impl Foo for [Fizz] under "Implementations on Foreign Types".

Possible Solution(s)

No response

Notes

No response

Version

[zack@laptop src]$ cargo version --verbose
cargo 1.79.0 (ffa9cf99a 2024-06-03)
release: 1.79.0
commit-hash: ffa9cf99a594e59032757403d4c780b46dc2c43a
commit-date: 2024-06-03
host: x86_64-unknown-linux-gnu
libgit2: 1.7.2 (sys:0.18.3 vendored)
libcurl: 8.6.0-DEV (sys:0.4.72+curl-8.6.0 vendored ssl:OpenSSL/1.1.1w)
ssl: OpenSSL 1.1.1w  11 Sep 2023
os: Arch Linux [64-bit]
epage commented 3 months ago

As rustdoc is generating this, transferring this.