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)] associated items of traits re-exported from external crates are not hidden in certain impl blocks #95717

Closed
fmease opened this issue Apr 6, 2022 · 1 comment · Fixed by #95769
Assignees
Labels
A-cross-crate-reexports Area: Documentation that has been re-exported from a different crate C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@fmease
Copy link
Member

fmease commented Apr 6, 2022

Minimal reproducible example (on stable and nightly):

// in crate `alpha`

pub trait Tr {
    #[doc(hidden)]
    type Assoc;
}

pub struct Ty;

impl Tr for Ty {
    type Assoc = ();
}
// in crate `beta` (which depends on `alpha`)

pub use alpha::{Tr, Ty};    // glob would also work

Document crate beta and take a look at the generated pages of Tr and Ty:
You should be able to actually see the associated type Assoc in the impl block despite being marked as hidden. You probably need to click [+] (expand) first.
The impl block I refer to is in section

  • Implementors on the trait page and in section
  • Trait Implementations on the implementor's page.

It should be noted that even though Assoc wrongly shows up in those impl blocks, it is indeed not shown in the code block at the start of the trait page – at the “definition site” if you will (compared to the “use sites” – the impl blocks).

It is crucial that the trait and the type are defined inside of an external crate. If they were defined in the “current” crate, this bug would not occur: The hidden associated items would not be shown.
You can check this for yourself by

  • documenting alpha on its own and viewing its documentation separately, or by
  • re-exporting the crate alpha from beta (e.g. with pub use alpha;) and then documenting beta:
    • On the page for alpha::Tr, the associated item is hidden
    • On the page for the re-export beta::Tr, however, the associated item is displayed

I've discovered this bug in a PR of mine after a CI job failed because the linkchecker complained about broken links in the standard library when documenting it with a modified rustdoc. The broken links are not relevant for this bug, they are mere symptoms of it: If everything was properly hidden, no broken links would ever be generated.

This bug currently affects the standard library documentation (for stable and nightly) as mentioned in the linked comment.
In this case,

  • the trait is SupportedLaneCount
  • the type is LaneCount
  • the associated type that shouldn't be shown is BitMask
  • crate “alpha” is core
  • crate “beta” is std

@rustbot label T-rustdoc A-cross-crate-reexports

@fmease fmease added the C-bug Category: This is a bug. label Apr 6, 2022
@rustbot rustbot added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Apr 6, 2022
@fmease fmease changed the title rustdoc: #[doc(hidden)] associated items of traits re-exported from external crates are not hidden in the impl section of both the trait and implementor pages rustdoc: #[doc(hidden)] associated items of traits re-exported from external crates are not hidden in certain impl blocks Apr 6, 2022
@rustbot rustbot added the A-cross-crate-reexports Area: Documentation that has been re-exported from a different crate label Apr 7, 2022
@fmease
Copy link
Member Author

fmease commented Apr 7, 2022

@rustbot claim

Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Apr 8, 2022
…Gomez

Hide cross-crate `#[doc(hidden)]` associated items in trait impls

Fixes rust-lang#95717.

r? `@GuillaumeGomez`
This is the bug I ran into in rust-lang#95316.

`@rustbot` label T-rustdoc A-cross-crate-reexports
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Apr 9, 2022
…Gomez

Hide cross-crate `#[doc(hidden)]` associated items in trait impls

Fixes rust-lang#95717.

r? ``@GuillaumeGomez``
This is the bug I ran into in rust-lang#95316.

``@rustbot`` label T-rustdoc A-cross-crate-reexports
@bors bors closed this as completed in 24fa80d Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cross-crate-reexports Area: Documentation that has been re-exported from a different crate 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

Successfully merging a pull request may close this issue.

2 participants