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

Always hide private fields in aliased type #124939

Merged
merged 1 commit into from May 12, 2024

Conversation

Urgau
Copy link
Contributor

@Urgau Urgau commented May 9, 2024

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 #124938
Fixes #123860

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels May 9, 2024
@workingjubilee
Copy link
Contributor

Based on discussion in #123860 the preferred implementation would seem to be to only hide these if the fields are from an "upstream" dependency and still reveal them if they're in the workspace.

@Urgau
Copy link
Contributor Author

Urgau commented May 9, 2024

That would indeed be better, but neither rustc nor rustdoc has workspace information, that is purely a Cargo concept. With RFC 3243: packages_as_namespaces we would have some sort a similar information, but I don't think it's possible to do it without it or without something else.

@workingjubilee
Copy link
Contributor

Ah, then it makes sense to defer the preferred implementation until later.

Copy link
Member

@GuillaumeGomez GuillaumeGomez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks! Please add a FIXME with a link to the cargo issue and open an issue here to keep track of it so it's not forgotten.

@Urgau Urgau force-pushed the hide-private-fields-aliased-type branch from 9b25ab4 to e89a2cc Compare May 11, 2024 11:14
@Urgau
Copy link
Contributor Author

Urgau commented May 11, 2024

Created issue #125009 to track the FIXME and added the it in the code.

@GuillaumeGomez
Copy link
Member

Thanks!

@bors r+ rollup

@bors
Copy link
Contributor

bors commented May 11, 2024

📌 Commit e89a2cc has been approved by GuillaumeGomez

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 11, 2024
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request 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 pull request 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 added a commit to rust-lang-ci/rust that referenced this pull request May 11, 2024
…llaumeGomez

Rollup of 6 pull requests

Successful merges:

 - rust-lang#124807 (Migrate `run-make/rustdoc-io-error` to `rmake.rs`)
 - rust-lang#124829 (Enable profiler for armv7-unknown-linux-gnueabihf.)
 - rust-lang#124939 (Always hide private fields in aliased type)
 - rust-lang#124963 (Migrate `run-make/rustdoc-shared-flags` to rmake)
 - rust-lang#124981 (Relax allocator requirements on some Rc/Arc APIs.)
 - rust-lang#125008 (Add test for rust-lang#122775)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request May 11, 2024
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#124096 (Clean up users of rust_dbg_call)
 - rust-lang#124829 (Enable profiler for armv7-unknown-linux-gnueabihf.)
 - rust-lang#124939 (Always hide private fields in aliased type)
 - rust-lang#124963 (Migrate `run-make/rustdoc-shared-flags` to rmake)
 - rust-lang#124981 (Relax allocator requirements on some Rc/Arc APIs.)
 - rust-lang#125008 (Add test for rust-lang#122775)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit beef360 into rust-lang:master May 12, 2024
6 checks passed
@rustbot rustbot added this to the 1.80.0 milestone May 12, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request 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
// the field and not the one given by the user for the currrent crate.
//
// FIXME(#125009): Not-local should probably consider same Cargo workspace
if !i.def_id().map_or(true, |did| did.is_local()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This caused all cross-crate type-aliased enums to stop rendering:

image

Because visibility() here returns None.

I'll put up a PR to fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
6 participants