Skip to content

rustdoc: How to render struct variants with no visible fields? #118195

Closed
@Kyuuhachi

Description

@Kyuuhachi
Contributor

While working on #118192, I noticed that struct variants with no (visible) fields look kinda awkward.

pub enum MyEnum {
	/// A variant with no fields
	A {},
	/// A variant with hidden fields
	B { #[doc(hidden)] a: u8 },
}

rendering of the above code snippet

The Fields heading takes a lot of space without adding particularly much to the content. The easiest solution would be to just remove the heading, but that would show no indication that there exist private fields. The same issue exists in top-level structs as well, but there it is mitigated by having the definition in the code block just above, while for enums there can be a sizeable distance between the two.

Any thoughts? Am I just overthinking the whole thing?

Activity

added
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Nov 23, 2023
added
T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
C-enhancementCategory: An issue proposing an enhancement or a PR with one.
A-rustdoc-uiArea: Rustdoc UI (generated HTML)
and removed
C-bugCategory: This is a bug.
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Nov 23, 2023
GuillaumeGomez

GuillaumeGomez commented on Dec 4, 2023

@GuillaumeGomez
Member

No this is a very good point. If there are no fields, we shouldn't add the "Fields" heading. Sending a fix.

added 2 commits that reference this issue on Dec 4, 2023

Rollup merge of rust-lang#118600 - GuillaumeGomez:fields-heading, r=n…

2d7b858

Rollup merge of rust-lang#118600 - GuillaumeGomez:fields-heading, r=n…

baa3f96
added a commit that references this issue on Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-rustdoc-uiArea: Rustdoc UI (generated HTML)C-enhancementCategory: An issue proposing an enhancement or a PR with one.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

      Participants

      @Kyuuhachi@GuillaumeGomez@fmease@rustbot

      Issue actions

        rustdoc: How to render struct variants with no visible fields? · Issue #118195 · rust-lang/rust