about summary refs log tree commit diff
path: root/library/core/src
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2023-08-15 14:29:46 +0200
committerGitHub <noreply@github.com>2023-08-15 14:29:46 +0200
commitf527d56c086842ac177c65ed09cf875cf0139bc0 (patch)
tree295a3e132ff1bdf3fcc336f5383ba2c3d9c22758 /library/core/src
parentf0987ab45b22a1568dfb23e003b85c7524b65f26 (diff)
parentfe1a034f16adbed4302e4d27be96a7ec6fb27177 (diff)
downloadrust-f527d56c086842ac177c65ed09cf875cf0139bc0.tar.gz
rust-f527d56c086842ac177c65ed09cf875cf0139bc0.zip
Rollup merge of #114800 - RalfJung:transparent, r=cuviper
std: add some missing repr(transparent)

For some types we don't want to stably guarantee this, so hide the `repr` from rustdoc. This nice approach was suggested by `@thomcc.`
Diffstat (limited to 'library/core/src')
-rw-r--r--library/core/src/ffi/c_str.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/library/core/src/ffi/c_str.rs b/library/core/src/ffi/c_str.rs
index b59ec12790d..4082b208c12 100644
--- a/library/core/src/ffi/c_str.rs
+++ b/library/core/src/ffi/c_str.rs
@@ -82,12 +82,12 @@ use crate::str;
 #[stable(feature = "core_c_str", since = "1.64.0")]
 #[rustc_has_incoherent_inherent_impls]
 #[lang = "CStr"]
-// FIXME:
 // `fn from` in `impl From<&CStr> for Box<CStr>` current implementation relies
 // on `CStr` being layout-compatible with `[u8]`.
-// When attribute privacy is implemented, `CStr` should be annotated as `#[repr(transparent)]`.
-// Anyway, `CStr` representation and layout are considered implementation detail, are
-// not documented and must not be relied upon.
+// However, `CStr` layout is considered an implementation detail and must not be relied upon. We
+// want `repr(transparent)` but we don't want it to show up in rustdoc, so we hide it under
+// `cfg(doc)`. This is an ad-hoc implementation of attribute privacy.
+#[cfg_attr(not(doc), repr(transparent))]
 pub struct CStr {
     // FIXME: this should not be represented with a DST slice but rather with
     //        just a raw `c_char` along with some form of marker to make