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
Minimal reproducible example (on stable and nightly):
Document crate
betaand take a look at the generated pages ofTrandTy:You should be able to actually see the associated type
Associn theimplblock despite being marked as hidden. You probably need to click[+](expand) first.The
implblock I refer to is in sectionIt should be noted that even though
Assocwrongly shows up in thoseimplblocks, 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” – theimplblocks).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
alphaon its own and viewing its documentation separately, or byalphafrombeta(e.g. withpub use alpha;) and then documentingbeta:alpha::Tr, the associated item is hiddenbeta::Tr, however, the associated item is displayedI'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,
SupportedLaneCountLaneCountBitMaskcorestd@rustbot label T-rustdoc A-cross-crate-reexports