Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Private fields in aliased type should not be shown #124938

Closed
Urgau opened this issue May 9, 2024 · 2 comments · Fixed by #124939
Closed

Private fields in aliased type should not be shown #124938

Urgau opened this issue May 9, 2024 · 2 comments · Fixed by #124939
Assignees
Labels
A-rustdoc-ui Area: rustdoc UI (generated HTML) C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@Urgau
Copy link
Member

Urgau commented May 9, 2024

I tried this code:

use std::collections::BTreeMap;

pub type FooBar = BTreeMap<u32, String>;

with rustdoc and --document-private-items.

I expected to see this happen: No internal fields of the BTreeMap should be displayed as users won't be able to use the fields, making their appearance confusing and useless.

Instead, this happened: The internal fields of the BTreeMap are displayed

image

Real impact as can be seen here.

Meta

rustdoc --version --verbose:

rustdoc 1.80.0-nightly (7d83a4c13 2024-05-06)
binary: rustdoc
commit-hash: 7d83a4c131ab9ae81a74c6fd825c827d74a2881d
commit-date: 2024-05-06
host: x86_64-unknown-linux-gnu
release: 1.80.0-nightly
LLVM version: 18.1.4
@Urgau Urgau added the C-bug Category: This is a bug. label May 9, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 9, 2024
@Urgau Urgau changed the title Private items in aliased type should not be shown Private fields in aliased type should not be shown May 9, 2024
@Urgau
Copy link
Member Author

Urgau commented May 9, 2024

@rustbot labels +T-rustdoc +A-rustdoc-ui -needs-triage
@rustbot claim

@rustbot rustbot added A-rustdoc-ui Area: rustdoc UI (generated HTML) T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels May 9, 2024
@lqd
Copy link
Member

lqd commented May 9, 2024

Dupe of #123860 and more discussion there

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue May 11, 2024
…type, r=GuillaumeGomez

Always hide private fields in aliased type

This PR adds a new rustdoc pass that unconditionally always strips all private fields in aliased type, since showing them, even with `--document-private-items`, is confusing, unhelpful, and run backwards to the "Aliased type" feature, which is to show the type as it would be seen by the user.

r? `@GuillaumeGomez`
Fixes rust-lang#124938
Fixes rust-lang#123860
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue May 11, 2024
…type, r=GuillaumeGomez

Always hide private fields in aliased type

This PR adds a new rustdoc pass that unconditionally always strips all private fields in aliased type, since showing them, even with `--document-private-items`, is confusing, unhelpful, and run backwards to the "Aliased type" feature, which is to show the type as it would be seen by the user.

r? ``@GuillaumeGomez``
Fixes rust-lang#124938
Fixes rust-lang#123860
@bors bors closed this as completed in beef360 May 12, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue May 12, 2024
Rollup merge of rust-lang#124939 - Urgau:hide-private-fields-aliased-type, r=GuillaumeGomez

Always hide private fields in aliased type

This PR adds a new rustdoc pass that unconditionally always strips all private fields in aliased type, since showing them, even with `--document-private-items`, is confusing, unhelpful, and run backwards to the "Aliased type" feature, which is to show the type as it would be seen by the user.

r? ```@GuillaumeGomez```
Fixes rust-lang#124938
Fixes rust-lang#123860
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-ui Area: rustdoc UI (generated HTML) C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants