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: doc(hidden) methods from traits show up on implementors #86145

Closed
jsha opened this issue Jun 8, 2021 · 2 comments
Closed

rustdoc: doc(hidden) methods from traits show up on implementors #86145

jsha opened this issue Jun 8, 2021 · 2 comments
Labels
A-rustdoc-ui Area: Rustdoc UI (generated HTML) C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@jsha
Copy link
Contributor

jsha commented Jun 8, 2021

The __iterator_get_unchecked method on Iterator is doc(hidden): https://doc.rust-lang.org/nightly/src/core/iter/traits/iterator.rs.html#3425-3437, and it is correctly hidden in the main part of Iterator's page. However, it still shows up in the Implementations section of structs that implement the trait, like std::str::Bytes:

https://doc.rust-lang.org/1.52.0/std/str/struct.Bytes.html#method.__iterator_get_unchecked

The method should be hidden in all contexts.

@jsha jsha added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. C-bug Category: This is a bug. A-rustdoc-ui Area: Rustdoc UI (generated HTML) labels Jun 8, 2021
@jsha
Copy link
Contributor Author

jsha commented Jun 8, 2021

Looking at implementations of __iterator_get_unchecked in std, it looks like about half have doc(hidden) on the implementation too. So for now I'm going to fix my immediate issue by making sure all implementations have doc(hidden). Maybe that's the overall solution too - say that doc(hidden) only applies to the trait item, and if implementations want to hide their copy, they have to do that manually.

JohnTitor added a commit to JohnTitor/rust that referenced this issue Jun 17, 2021
…=GuillaumeGomez

Remove methods under Implementors on trait pages

As discussed at rust-lang#84326 (comment).

On a trait page, the "Implementors" section currently lists all methods of each implementor. That duplicates the method definitions on the trait itself, and is usually not very useful. So the implementors are collapsed by default. This PR changes rustdoc to just not render them at all. Any documentation specific to an implementor can be found by clicking through to the implementor's page.

This moves the "portability" info inside the `<summary>` tags so it is still visible on trait pages (as originally implemented in rust-lang#79201). That also means it will be visible on struct/enum pages when methods are collapsed.

Add `#[doc(hidden)]` to all implementations of `Iterator::__iterator_get_unchecked` that didn't already have it. Otherwise, due to rust-lang#86145, the structs/enums with those implementations would generate documentation for them, and that documentation would have a broken link into the Iterator page. Those links were already "broken" but not detected by the link-checker, because they pointed to one of the Implementors on the Iterator page, which happened to have the right anchor name.

This reduces the Read trait's page size from 128kB to 68kB (uncompressed) and from 12,125 bytes to 9,989 bytes (gzipped
Demo:

https://hoffman-andrews.com/rust/remove-methods-implementors/std/string/struct.String.html#trait-implementations
https://hoffman-andrews.com/rust/remove-methods-implementors/std/io/trait.Read.html#implementors

r? `@GuillaumeGomez`
@jyn514
Copy link
Member

jyn514 commented Jul 2, 2021

Duplicate of #36035

@jyn514 jyn514 marked this as a duplicate of #36035 Jul 2, 2021
@jyn514 jyn514 closed this as completed Jul 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-ui Area: Rustdoc UI (generated HTML) 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

No branches or pull requests

2 participants