-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Description
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 workDocument 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
alphaon its own and viewing its documentation separately, or by - re-exporting the crate
alphafrombeta(e.g. withpub use alpha;) and then documentingbeta:- 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
- On the page for
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