Skip to content

rustdoc: Don't distinguish structs and tuple structs with only private fields #38101

@clarfonthey

Description

@clarfonthey
Contributor

For example, AddrParseError shows up as pub struct AddrParseError(_); and Ipv4Addr shows up as pub struct Ipv4Addr { /* fields omitted */ }

I feel like all structs should show up as the latter form if all of the fields are private. It technically doesn't matter that the struct is a tuple struct if the fields are all private. It's not a huge deal but it's an inconsistency that looks off to me.

Activity

added
T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
on Dec 1, 2016
bluss

bluss commented on Dec 1, 2016

@bluss
Member

Yes, it is time, because the relevant part of #35626 is stable in nightly.

added
T-dev-toolsRelevant to the dev-tools subteam, which will review and decide on the PR/issue.
and removed on May 18, 2017
steveklabnik

steveklabnik commented on Jan 9, 2020

@steveklabnik
Member

Triage: this bug still reproduces

removed
T-dev-toolsRelevant to the dev-tools subteam, which will review and decide on the PR/issue.
on Jan 18, 2022
clarfonthey

clarfonthey commented on Feb 7, 2022

@clarfonthey
ContributorAuthor

This bug still reproduces, in case you were wondering.

jsha

jsha commented on Feb 8, 2022

@jsha
Contributor

/cc @camelid who might be interested because it's similar in nature to #92699.

camelid

camelid commented on Feb 9, 2022

@camelid
Member

Yeah, it's always bothered me that tuple structs with all private fields show how many fields they have, even though they're supposed to be fully private.

self-assigned this
on Feb 9, 2022
clarfonthey

clarfonthey commented on Feb 9, 2022

@clarfonthey
ContributorAuthor

Bonus points if you make it so that it has the struct-field syntax if there are a mix of private/public fields, e.g. Struct { 1: T, /* some fields hidden */ }

camelid

camelid commented on Feb 10, 2022

@camelid
Member

In that case, I think I might make it look like Struct(..., T, ...) or Struct(/* private fields */, T, /* private fields */). Preferences?

clarfonthey

clarfonthey commented on Feb 11, 2022

@clarfonthey
ContributorAuthor

The main benefit of the struct-based syntax is that it's actually valid Rust syntax, but if you don't care about that, the latter also works. I don't believe that there's any tuple-based syntax that works like that.

camelid

camelid commented on Feb 11, 2022

@camelid
Member

The main benefit of the struct-based syntax is that it's actually valid Rust syntax, but if you don't care about that, the latter also works. I don't believe that there's any tuple-based syntax that works like that.

Struct { 1: T } doesn't seem to be valid syntax, unless you were referring to something else?

changed the title [-]docs: Don't distinguish structs and tuple structs with only private fields[/-] [+]rustdoc: Don't distinguish structs and tuple structs with only private fields[/+] on Feb 11, 2022
clarfonthey

clarfonthey commented on Feb 11, 2022

@clarfonthey
ContributorAuthor

So, I should have clarified: Struct { 1: T } isn't a valid struct definition, but Struct { 1: x } is a valid pattern. So, I guess what I meant to say was that it's closer to valid Rust syntax, although it's still invalid.

added
E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.
on Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

C-feature-requestCategory: A feature request, i.e: not implemented / a PR.E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.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

      Participants

      @steveklabnik@ehuss@jsha@bluss@Mark-Simulacrum

      Issue actions

        rustdoc: Don't distinguish structs and tuple structs with only private fields · Issue #38101 · rust-lang/rust