-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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: Trait implementations aren't listed in generated docs under some circumstances #36922
Comments
@alexcrichton Ugh, the way What's needed is a |
@eddyb I think rustdoc's slogan is "dubious at best" |
This bug is particularly confusing for crates that use Serde. Right now auto-derived implementations of Serialize/Deserialize don't show up in rustdoc. |
The 'dummy const' pattern was copied from SerDe[1], but it causes rustdoc not to generate documentation due to a [known bug][2]. Apparently SerDe [considered][3] using a dummy module instead of a dummy const, but decided against it due to private type issues. Since everything's public in `prost`, we shouldn't have such an issue. Also removes #[automatically_derived] annotations, since apparently the no longer do anything[4]. Fixes #11 [1]: https://github.com/serde-rs/serde/blob/775e8154e7151eb1576d65df539c4ac1612595c6/serde_derive/src/ser.rs#L28 [2]: rust-lang/rust#36922 [3]: serde-rs/serde#159 (comment) [4]: https://botbot.me/mozilla/rust/2017-07-11/?msg=88402326&page=3
The 'dummy const' pattern was copied from SerDe[1], but it causes rustdoc not to generate documentation due to a [known bug][2]. Apparently SerDe [considered][3] using a dummy module instead of a dummy const, but decided against it due to private type issues. Since everything's public in `prost`, we shouldn't have such an issue. Also removes #[automatically_derived] annotations, since apparently the no longer do anything[4]. Fixes #11 [1]: https://github.com/serde-rs/serde/blob/775e8154e7151eb1576d65df539c4ac1612595c6/serde_derive/src/ser.rs#L28 [2]: rust-lang/rust#36922 [3]: serde-rs/serde#159 (comment) [4]: https://botbot.me/mozilla/rust/2017-07-11/?msg=88402326&page=3
The 'dummy const' pattern was copied from SerDe[1], but it causes rustdoc not to generate documentation due to a [known bug][2]. Apparently SerDe [considered][3] using a dummy module instead of a dummy const, but decided against it due to private type issues. Since everything's public in `prost`, we shouldn't have such an issue. Also removes #[automatically_derived] annotations, since apparently the no longer do anything[4]. Fixes #11 [1]: https://github.com/serde-rs/serde/blob/775e8154e7151eb1576d65df539c4ac1612595c6/serde_derive/src/ser.rs#L28 [2]: rust-lang/rust#36922 [3]: serde-rs/serde#159 (comment) [4]: https://botbot.me/mozilla/rust/2017-07-11/?msg=88402326&page=3
Whew! This is super confusing! |
I've opened #53162 to fix this. |
…=GuillaumeGomez rustdoc: collect trait impls as an early pass Fixes #52545, fixes #41480, fixes #36922 Right now, rustdoc pulls all its impl information by scanning a crate's HIR for any items it finds. However, it doesn't recurse into anything other than modules, preventing it from seeing trait impls that may be inside things like functions or consts. Thanks to #53002, now these items actually *exist* for rustdoc to see, but they still weren't getting collected for display. But there was a secret. Whenever we pull in an item from another crate, we don't have any of its impls in the local HIR, so instead we ask the compiler for *everything* and filter out after the fact. This process is only triggered if there's a cross-crate re-export in the crate being documented, which can sometimes leave this info out of the docs. This PR instead moves this collection into an early pass, which occurs immediately after crate cleaning, so that that collection occurs regardless. In addition, by including the HIR's own `trait_impls` in addition to the existing `all_trait_implementations` calls, we can collect all these tricky trait impls without having to scan for them!
…en-trait, r=GuillaumeGomez rustdoc: collect trait impls as an early pass Fixes rust-lang#52545, fixes rust-lang#41480, fixes rust-lang#36922 Right now, rustdoc pulls all its impl information by scanning a crate's HIR for any items it finds. However, it doesn't recurse into anything other than modules, preventing it from seeing trait impls that may be inside things like functions or consts. Thanks to rust-lang#53002, now these items actually *exist* for rustdoc to see, but they still weren't getting collected for display. But there was a secret. Whenever we pull in an item from another crate, we don't have any of its impls in the local HIR, so instead we ask the compiler for *everything* and filter out after the fact. This process is only triggered if there's a cross-crate re-export in the crate being documented, which can sometimes leave this info out of the docs. This PR instead moves this collection into an early pass, which occurs immediately after crate cleaning, so that that collection occurs regardless. In addition, by including the HIR's own `trait_impls` in addition to the existing `all_trait_implementations` calls, we can collect all these tricky trait impls without having to scan for them!
…en-trait, r=GuillaumeGomez rustdoc: collect trait impls as an early pass Fixes rust-lang#52545, fixes rust-lang#41480, fixes rust-lang#36922 Right now, rustdoc pulls all its impl information by scanning a crate's HIR for any items it finds. However, it doesn't recurse into anything other than modules, preventing it from seeing trait impls that may be inside things like functions or consts. Thanks to rust-lang#53002, now these items actually *exist* for rustdoc to see, but they still weren't getting collected for display. But there was a secret. Whenever we pull in an item from another crate, we don't have any of its impls in the local HIR, so instead we ask the compiler for *everything* and filter out after the fact. This process is only triggered if there's a cross-crate re-export in the crate being documented, which can sometimes leave this info out of the docs. This PR instead moves this collection into an early pass, which occurs immediately after crate cleaning, so that that collection occurs regardless. In addition, by including the HIR's own `trait_impls` in addition to the existing `all_trait_implementations` calls, we can collect all these tricky trait impls without having to scan for them!
…=GuillaumeGomez rustdoc: collect trait impls as an early pass Fixes #52545, fixes #41480, fixes #36922 Right now, rustdoc pulls all its impl information by scanning a crate's HIR for any items it finds. However, it doesn't recurse into anything other than modules, preventing it from seeing trait impls that may be inside things like functions or consts. Thanks to #53002, now these items actually *exist* for rustdoc to see, but they still weren't getting collected for display. But there was a secret. Whenever we pull in an item from another crate, we don't have any of its impls in the local HIR, so instead we ask the compiler for *everything* and filter out after the fact. This process is only triggered if there's a cross-crate re-export in the crate being documented, which can sometimes leave this info out of the docs. This PR instead moves this collection into an early pass, which occurs immediately after crate cleaning, so that that collection occurs regardless. In addition, by including the HIR's own `trait_impls` in addition to the existing `all_trait_implementations` calls, we can collect all these tricky trait impls without having to scan for them!
Serde's
Deserialize
andSerialize
traits don't show up in the "Trait Implementations" section for types that use custom derive through Macros 1.1 or through Syntex. Alex Crichton also notes that rustdoc does not displayCopy
in the "Trait Implementations" section with the following code:I've only tested this on nightly Rust.
The text was updated successfully, but these errors were encountered: