Eliminate use of #[cfg_attr(not(doc), repr(...))]#116743
Eliminate use of #[cfg_attr(not(doc), repr(...))]#116743dtolnay wants to merge 1 commit intorust-lang:masterfrom
#[cfg_attr(not(doc), repr(...))]#116743Conversation
|
r? @m-ou-se (rustbot has picked a reviewer for you, use r? to override) |
|
Portable SIMD is developed in its own repository. If possible, consider making this change to rust-lang/portable-simd instead. |
27411f9 to
56f472d
Compare
|
|
There was a problem hiding this comment.
This can't land as is, I'm afraid. My PR only affects the transparent representation. I've totally overlooked non-transparent reprs but in my defense nobody has mentioned this either over at the issue and the PR.
It does make sense though to extend this behavior to other reprs 🤦. I will open a PR as soon as possible.
CC @RalfJung
| #[doc = include_str!("c_void.md")] | ||
| #[lang = "c_void"] | ||
| #[cfg_attr(not(doc), repr(u8))] // work around https://github.com/rust-lang/rust/issues/90435 | ||
| #[repr(u8)] |
There was a problem hiding this comment.
Unfortunately, this will still show up in the docs, my PR only affects repr(transparent). Further, it doesn't take into account #[doc(hidden)] (in this case on variants). Arguably, rustdoc should hide #[repr(u8)] and respect doc(hidden). I can send a PR right away.
There was a problem hiding this comment.
Shouldn't we keep non-transparent reprs for enums though? It's useful, especially repr(c) ones for FFI.
There was a problem hiding this comment.
For sure, but in this case both variants are doc(hidden). I plan on hiding those reprs if all variants are hidden.
| not(windows), | ||
| ))] | ||
| #[cfg_attr(not(doc), repr(C))] // work around https://github.com/rust-lang/rust/issues/66401 | ||
| #[repr(C)] |
There was a problem hiding this comment.
Similarly, repr(C) is still going to show up in the docs :| Let me update rustdoc to handle that as well.
…rk-Simulacrum Request that rust-analyzer changes are sent upstream first if possible This automates `@lnicola's` comment rust-lang#118253 (comment). Rustbot will write a comment similar to rust-lang#116743 (comment).
Rollup merge of rust-lang#118255 - dtolnay:mentionsrustanalyzer, r=Mark-Simulacrum Request that rust-analyzer changes are sent upstream first if possible This automates `@lnicola's` comment rust-lang#118253 (comment). Rustbot will write a comment similar to rust-lang#116743 (comment).
|
I'll rebase and reopen if #116882 makes progress. |
…c, r=<try> rustdoc: hide `#[repr]` if it isn't part of the public ABI Follow-up to #115439. Unblocks #116743, CC `@dtolnay.` Fixes #128364. Fixes #137440. Only display the representation `#[repr(REPR)]` (where `REPR` is not `Rust` or `transparent`) of a given type if the type is not `#[non_exhaustive]`, if none of its variants (incl. the synthetic variants of structs) are `#[doc(hidden)]` or `#[non_exhaustive]` and if all of its fields are public and not `#[doc(hidden)]` since it's likely not meant to be considered part of the public ABI otherwise. `--document-{private,hidden}-items` works as expected in this context, too. Moreover, we now also factor in the presence of `#[doc(hidden)]` and of `#[non_exhaustive]` when checking whether to show `repr(transparent)` or not.
…pr-heuristic, r=rustdoc rustdoc: hide `#[repr]` if it isn't part of the public ABI > [!IMPORTANT] > Temporarily stacked on top of PR rust-lang#146527; only the last commit is relevant! Follow-up to rust-lang#115439. Unblocks rust-lang#116743, CC `@dtolnay.` Fixes rust-lang#66401. Fixes rust-lang#128364. Fixes rust-lang#137440. Only display the representation `#[repr(REPR)]` (where `REPR` is not `Rust` or `transparent`) of a given type if none of its variants (incl. the synthetic variants of structs) are `#[doc(hidden)]` and all of its fields are public and not `#[doc(hidden)]` since it's likely not meant to be considered part of the public ABI otherwise. `--document-{private,hidden}-items` works as expected in this context, too. Moreover, we now also factor in the presence of `#[doc(hidden)]` when checking whether to show `repr(transparent)` or not.
…pr-heuristic, r=rustdoc rustdoc: hide `#[repr]` if it isn't part of the public ABI > [!IMPORTANT] > Temporarily stacked on top of PR rust-lang#146527; only the last commit is relevant! Follow-up to rust-lang#115439. Unblocks rust-lang#116743, CC ``@dtolnay.`` Fixes rust-lang#66401. Fixes rust-lang#128364. Fixes rust-lang#137440. Only display the representation `#[repr(REPR)]` (where `REPR` is not `Rust` or `transparent`) of a given type if none of its variants (incl. the synthetic variants of structs) are `#[doc(hidden)]` and all of its fields are public and not `#[doc(hidden)]` since it's likely not meant to be considered part of the public ABI otherwise. `--document-{private,hidden}-items` works as expected in this context, too. Moreover, we now also factor in the presence of `#[doc(hidden)]` when checking whether to show `repr(transparent)` or not.
Rollup merge of #116882 - fmease:rustdoc-generalized-priv-repr-heuristic, r=rustdoc rustdoc: hide `#[repr]` if it isn't part of the public ABI > [!IMPORTANT] > Temporarily stacked on top of PR #146527; only the last commit is relevant! Follow-up to #115439. Unblocks #116743, CC ``@dtolnay.`` Fixes #66401. Fixes #128364. Fixes #137440. Only display the representation `#[repr(REPR)]` (where `REPR` is not `Rust` or `transparent`) of a given type if none of its variants (incl. the synthetic variants of structs) are `#[doc(hidden)]` and all of its fields are public and not `#[doc(hidden)]` since it's likely not meant to be considered part of the public ABI otherwise. `--document-{private,hidden}-items` works as expected in this context, too. Moreover, we now also factor in the presence of `#[doc(hidden)]` when checking whether to show `repr(transparent)` or not.
…tic, r=rustdoc rustdoc: hide `#[repr]` if it isn't part of the public ABI > [!IMPORTANT] > Temporarily stacked on top of PR rust-lang/rust#146527; only the last commit is relevant! Follow-up to rust-lang/rust#115439. Unblocks rust-lang/rust#116743, CC ``@dtolnay.`` Fixes rust-lang/rust#66401. Fixes rust-lang/rust#128364. Fixes rust-lang/rust#137440. Only display the representation `#[repr(REPR)]` (where `REPR` is not `Rust` or `transparent`) of a given type if none of its variants (incl. the synthetic variants of structs) are `#[doc(hidden)]` and all of its fields are public and not `#[doc(hidden)]` since it's likely not meant to be considered part of the public ABI otherwise. `--document-{private,hidden}-items` works as expected in this context, too. Moreover, we now also factor in the presence of `#[doc(hidden)]` when checking whether to show `repr(transparent)` or not.
Library: Remove remaining private `#[repr]` workarounds With rust-lang#116882 finally merged, gating these `repr`s behind cfg `not(doc)` is no longer necessary to achieve a private repr. Follow up to rust-lang#128046 (that was enabled via rust-lang#115439). With that, rust-lang#116743 is now fully realized at long last. cc `@dtolnay`
Library: Remove remaining private `#[repr]` workarounds With rust-lang#116882 finally merged, gating these `repr`s behind cfg `not(doc)` is no longer necessary to achieve a private repr. Follow up to rust-lang#128046 (that was enabled via rust-lang#115439). With that, rust-lang#116743 is now fully realized at long last. cc ``@dtolnay``
Rollup merge of #147095 - fmease:libprivrepr, r=dtolnay Library: Remove remaining private `#[repr]` workarounds With #116882 finally merged, gating these `repr`s behind cfg `not(doc)` is no longer necessary to achieve a private repr. Follow up to #128046 (that was enabled via #115439). With that, #116743 is now fully realized at long last. cc ``@dtolnay``
Library: Remove remaining private `#[repr]` workarounds With rust-lang#116882 finally merged, gating these `repr`s behind cfg `not(doc)` is no longer necessary to achieve a private repr. Follow up to rust-lang#128046 (that was enabled via rust-lang#115439). With that, rust-lang#116743 is now fully realized at long last. cc ``@dtolnay``
…tic, r=rustdoc rustdoc: hide `#[repr]` if it isn't part of the public ABI > [!IMPORTANT] > Temporarily stacked on top of PR rust-lang/rust#146527; only the last commit is relevant! Follow-up to rust-lang/rust#115439. Unblocks rust-lang/rust#116743, CC ``@dtolnay.`` Fixes rust-lang/rust#66401. Fixes rust-lang/rust#128364. Fixes rust-lang/rust#137440. Only display the representation `#[repr(REPR)]` (where `REPR` is not `Rust` or `transparent`) of a given type if none of its variants (incl. the synthetic variants of structs) are `#[doc(hidden)]` and all of its fields are public and not `#[doc(hidden)]` since it's likely not meant to be considered part of the public ABI otherwise. `--document-{private,hidden}-items` works as expected in this context, too. Moreover, we now also factor in the presence of `#[doc(hidden)]` when checking whether to show `repr(transparent)` or not.
…tic, r=rustdoc rustdoc: hide `#[repr]` if it isn't part of the public ABI > [!IMPORTANT] > Temporarily stacked on top of PR rust-lang/rust#146527; only the last commit is relevant! Follow-up to rust-lang/rust#115439. Unblocks rust-lang/rust#116743, CC ``@dtolnay.`` Fixes rust-lang/rust#66401. Fixes rust-lang/rust#128364. Fixes rust-lang/rust#137440. Only display the representation `#[repr(REPR)]` (where `REPR` is not `Rust` or `transparent`) of a given type if none of its variants (incl. the synthetic variants of structs) are `#[doc(hidden)]` and all of its fields are public and not `#[doc(hidden)]` since it's likely not meant to be considered part of the public ABI otherwise. `--document-{private,hidden}-items` works as expected in this context, too. Moreover, we now also factor in the presence of `#[doc(hidden)]` when checking whether to show `repr(transparent)` or not.
This PR reverts #107680 and some pre-existing occurrences of the same pattern.
The issue that prompted the workaround, #90435, has since been fixed by #115439.
Tested by running
x.py doc --stage 1 library/stdand confirming that std/path/struct.PathBuf.html contains no visible#[repr(transparent)]. Note thatx.py doc library/stdruns using stage0 rustdoc (maybe depending on config.toml?) and will continue to render a#[repr(transparent)], but that's okay and shouldn't make it into official documentation of the 1.75.0 release.Blocked on #116882