Open dtolnay opened 3 months ago
If I remember correctly my open PR #116882 from Oct '23 addresses this. It's still blocked on design decisions:
It's not entirely clear to me yet when exactly a repr is considered public or private. What I've implemented: A repr is public iff
- there exists a variant[^1] that is not
doc(hidden)
or there are no variants at all and- for all struct fields (excl. enum variant struct fields) field, field is
pub
and notdoc(hidden)
(while respecting
--document-{private,hidden}-items
of course).However, it's not clear to me if the quantifiers above are correct, should they be swapped around or sth. else? Moreover, should we take the visibility of enum variant struct fields into account?
[^1]: Here, variant refers to a (general) variant of an ADT which includes not only enum variants but also the single synthetic variant of structs and unions
Previous discussions of
repr
documentation:I believe the intent was that
repr(transparent)
should only appear in rendered documentation if the field's type is a public API that the documentation reader gets to rely on.This is the case for
repro::Public
, and not the case forrepro::Private
.I believe
repro::Hidden
should be treated more likerepro::Private
for the purpose of documenting repr.In the standard library, this currently impacts
core::pin::Pin
. https://doc.rust-lang.org/1.80.0/core/pin/struct.Pin.html