about summary refs log tree commit diff
path: root/src/doc
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-10-14 18:46:19 +0000
committerbors <bors@rust-lang.org>2023-10-14 18:46:19 +0000
commitee8c9d3c34719a129f280cd91ba5d324017bb02b (patch)
treee1ab870ec5d3cf3b4bc8e3875daf98c62c02c6fb /src/doc
parent8de6f99e32d576d1a0969b75e9b206a4a55c9f7b (diff)
parent77b578f72bbab10cc74581a6ef718b5395c4f2e5 (diff)
downloadrust-ee8c9d3c34719a129f280cd91ba5d324017bb02b.tar.gz
rust-ee8c9d3c34719a129f280cd91ba5d324017bb02b.zip
Auto merge of #116737 - matthiaskrgr:rollup-jftlnmt, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #115439 (rustdoc: hide `#[repr(transparent)]` if it isn't part of the public ABI)
 - #116591 (Don't accidentally detect the commit hash as an `fadd` instruction)
 - #116603 (Reorganize `bootstrap/Cargo.toml`)
 - #116715 (Prevent more spurious unreachable pattern lints)
 - #116723 (Fix broken build on ESP-IDF caused by #115108)
 - #116730 (Add some unsoundness tests for opaques capturing hidden regions not in substs)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'src/doc')
-rw-r--r--src/doc/rustdoc/src/advanced-features.md20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/doc/rustdoc/src/advanced-features.md b/src/doc/rustdoc/src/advanced-features.md
index dbf0baec04c..1733c8fc9a2 100644
--- a/src/doc/rustdoc/src/advanced-features.md
+++ b/src/doc/rustdoc/src/advanced-features.md
@@ -110,3 +110,23 @@ https://doc.rust-lang.org/stable/std/?search=%s&go_to_first=true
 
 This URL adds the `go_to_first=true` query parameter which can be appended to any `rustdoc` search URL
 to automatically go to the first result.
+
+## `#[repr(transparent)]`: Documenting the transparent representation
+
+You can read more about `#[repr(transparent)]` itself in the [Rust Reference][repr-trans-ref] and
+in the [Rustonomicon][repr-trans-nomicon].
+
+Since this representation is only considered part of the public ABI if the single field with non-trivial
+size or alignment is public and if the documentation does not state otherwise, Rustdoc helpfully displays
+the attribute if and only if the non-1-ZST field is public or at least one field is public in case all
+fields are 1-ZST fields. The term *1-ZST* refers to types that are one-aligned and zero-sized.
+
+It would seem that one can manually hide the attribute with `#[cfg_attr(not(doc), repr(transparent))]`
+if one wishes to declare the representation as private even if the non-1-ZST field is public.
+However, due to [current limitations][cross-crate-cfg-doc], this method is not always guaranteed to work.
+Therefore, if you would like to do so, you should always write it down in prose independently of whether
+you use `cfg_attr` or not.
+
+[repr-trans-ref]: https://doc.rust-lang.org/reference/type-layout.html#the-transparent-representation
+[repr-trans-nomicon]: https://doc.rust-lang.org/nomicon/other-reprs.html#reprtransparent
+[cross-crate-cfg-doc]: https://github.com/rust-lang/rust/issues/114952