Skip to content

Repr is incorrectly documented for structs with hidden field #128364

@dtolnay

Description

@dtolnay
#[repr(transparent)]
pub struct Public {
    pub field: i32,
}

#[repr(transparent)]
pub struct Private {
    field: i32,
}

#[repr(transparent)]
pub struct Hidden {
    #[doc(hidden)]
    pub field: i32,
}
Screenshot 2024-07-29 at 1 46 31 PM Screenshot 2024-07-29 at 1 46 15 PM Screenshot 2024-07-29 at 1 46 22 PM

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 for repro::Private.

I believe repro::Hidden should be treated more like repro::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

Metadata

Metadata

Assignees

Labels

A-attributesArea: Attributes (`#[…]`, `#![…]`)A-reprArea: the `#[repr(stuff)]` attributeC-bugCategory: This is a bug.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions