Skip to content

Hiding of struct declarations means constructability isn't really documented #51860

Closed
@clarfonthey

Description

@clarfonthey

This was found in review of #51854, which affects the documentation for #[non_exhaustive] and is a prerequisite for stabilisation.

Previously, the /* fields omitted */ comment would be a statement to the reader that the struct has private fields, and is thus not constructable. However, now that these declarations are hidden by default, this isn't really documented in something in the open.

In order to properly document the non-exhaustiveness of a struct, it makes sense that the constructability of a struct also be documented, as this is the primary reason for marking a struct as non-exhaustive in the first place.

My thoughts: structs which are constructable are rarer than those that aren't, so I think that a message that states so on these types would be best. As I mentioned in the linked PR, it would be something along the lines of "all of this struct's fields are public, and it can be constructed normally with the Struct { .. } syntax."

Metadata

Metadata

Assignees

No one assigned

    Labels

    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