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

doc(cfg) doesn't inherit down onto trait impls in modules #79201

Closed
Nemo157 opened this issue Nov 19, 2020 · 2 comments · Fixed by #79349
Closed

doc(cfg) doesn't inherit down onto trait impls in modules #79201

Nemo157 opened this issue Nov 19, 2020 · 2 comments · Fixed by #79349
Assignees
Labels
C-bug Category: This is a bug. F-doc_cfg `#![feature(doc_cfg)]` T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@Nemo157
Copy link
Member

Nemo157 commented Nov 19, 2020

I tried this code:

#![feature(doc_cfg)]

pub trait Foo {}

#[doc(cfg(feature = "foobar"))]
impl crate::Foo for usize {}

#[doc(cfg(feature = "foobar"))]
mod imp {
    impl crate::Foo for () {}
}

I expected to see this happen: both impls being highlighted as needing the foobar feature.

Instead, this happened: only the usize impl got the message:

image

Meta

rustdoc 1.50.0-nightly (825637983 2020-11-18)
binary: rustdoc
commit-hash: 8256379832b5ecb7f71e8c5e2018446482223c12
commit-date: 2020-11-18
host: x86_64-unknown-linux-gnu
release: 1.50.0-nightly
@Nemo157 Nemo157 added the C-bug Category: This is a bug. label Nov 19, 2020
@Nemo157
Copy link
Member Author

Nemo157 commented Nov 19, 2020

@rustbot modify labels: +T-rustdoc

@rustbot rustbot added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Nov 19, 2020
@Nemo157
Copy link
Member Author

Nemo157 commented Nov 19, 2020

@rustbot claim

@jyn514 jyn514 added the F-doc_cfg `#![feature(doc_cfg)]` label Nov 21, 2020
@bors bors closed this as completed in 9eb3a7c Dec 12, 2020
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`
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. F-doc_cfg `#![feature(doc_cfg)]` 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