1
Fork 0

actually this doesn't even affect doctests. nice.

This commit is contained in:
Ralf Jung 2023-08-14 22:55:29 +02:00
parent f887f5a9c6
commit fe1a034f16
3 changed files with 12 additions and 24 deletions

View file

@ -82,14 +82,11 @@ use crate::str;
#[stable(feature = "core_c_str", since = "1.64.0")] #[stable(feature = "core_c_str", since = "1.64.0")]
#[rustc_has_incoherent_inherent_impls] #[rustc_has_incoherent_inherent_impls]
#[lang = "CStr"] #[lang = "CStr"]
// FIXME:
// `fn from` in `impl From<&CStr> for Box<CStr>` current implementation relies // `fn from` in `impl From<&CStr> for Box<CStr>` current implementation relies
// on `CStr` being layout-compatible with `[u8]`. // on `CStr` being layout-compatible with `[u8]`.
// When attribute privacy is implemented, `CStr` should be annotated as `#[repr(transparent)]`. // However, `CStr` layout is considered an implementation detail and must not be relied upon. We
// Anyway, `CStr` representation and layout are considered implementation detail, are // want `repr(transparent)` but we don't want it to show up in rustdoc, so we hide it under
// not documented and must not be relied upon. // `cfg(doc)`. This is an ad-hoc implementation of attribute privacy.
// For now we just hide this from rustdoc, technically making our doc test builds rely on
// unspecified layout assumptions. We are std, so we can get away with that.
#[cfg_attr(not(doc), repr(transparent))] #[cfg_attr(not(doc), repr(transparent))]
pub struct CStr { pub struct CStr {
// FIXME: this should not be represented with a DST slice but rather with // FIXME: this should not be represented with a DST slice but rather with

View file

@ -110,14 +110,11 @@ impl crate::sealed::Sealed for OsString {}
/// [conversions]: super#conversions /// [conversions]: super#conversions
#[cfg_attr(not(test), rustc_diagnostic_item = "OsStr")] #[cfg_attr(not(test), rustc_diagnostic_item = "OsStr")]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
// FIXME:
// `OsStr::from_inner` current implementation relies // `OsStr::from_inner` current implementation relies
// on `OsStr` being layout-compatible with `Slice`. // on `OsStr` being layout-compatible with `Slice`.
// When attribute privacy is implemented, `OsStr` should be annotated as `#[repr(transparent)]`. // However, `OsStr` layout is considered an implementation detail and must not be relied upon. We
// Anyway, `OsStr` representation and layout are considered implementation details, are // want `repr(transparent)` but we don't want it to show up in rustdoc, so we hide it under
// not documented and must not be relied upon. // `cfg(doc)`. This is an ad-hoc implementation of attribute privacy.
// For now we just hide this from rustdoc, technically making our doc test builds rely on
// unspecified layout assumptions. We are std, so we can get away with that.
#[cfg_attr(not(doc), repr(transparent))] #[cfg_attr(not(doc), repr(transparent))]
pub struct OsStr { pub struct OsStr {
inner: Slice, inner: Slice,

View file

@ -1158,14 +1158,11 @@ impl FusedIterator for Ancestors<'_> {}
/// Which method works best depends on what kind of situation you're in. /// Which method works best depends on what kind of situation you're in.
#[cfg_attr(not(test), rustc_diagnostic_item = "PathBuf")] #[cfg_attr(not(test), rustc_diagnostic_item = "PathBuf")]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
// FIXME:
// `PathBuf::as_mut_vec` current implementation relies // `PathBuf::as_mut_vec` current implementation relies
// on `PathBuf` being layout-compatible with `Vec<u8>`. // on `PathBuf` being layout-compatible with `Vec<u8>`.
// When attribute privacy is implemented, `PathBuf` should be annotated as `#[repr(transparent)]`. // However, `PathBuf` layout is considered an implementation detail and must not be relied upon. We
// Anyway, `PathBuf` representation and layout are considered implementation detail, are // want `repr(transparent)` but we don't want it to show up in rustdoc, so we hide it under
// not documented and must not be relied upon. // `cfg(doc)`. This is an ad-hoc implementation of attribute privacy.
// For now we just hide this from rustdoc, technically making our doc test builds rely on
// unspecified layout assumptions. We are std, so we can get away with that.
#[cfg_attr(not(doc), repr(transparent))] #[cfg_attr(not(doc), repr(transparent))]
pub struct PathBuf { pub struct PathBuf {
inner: OsString, inner: OsString,
@ -1986,14 +1983,11 @@ impl AsRef<OsStr> for PathBuf {
/// ``` /// ```
#[cfg_attr(not(test), rustc_diagnostic_item = "Path")] #[cfg_attr(not(test), rustc_diagnostic_item = "Path")]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
// FIXME:
// `Path::new` current implementation relies // `Path::new` current implementation relies
// on `Path` being layout-compatible with `OsStr`. // on `Path` being layout-compatible with `OsStr`.
// When attribute privacy is implemented, `Path` should be annotated as `#[repr(transparent)]`. // However, `Path` layout is considered an implementation detail and must not be relied upon. We
// Anyway, `Path` representation and layout are considered implementation detail, are // want `repr(transparent)` but we don't want it to show up in rustdoc, so we hide it under
// not documented and must not be relied upon. // `cfg(doc)`. This is an ad-hoc implementation of attribute privacy.
// For now we just hide this from rustdoc, technically making our doc test builds rely on
// unspecified layout assumptions. We are std, so we can get away with that.
#[cfg_attr(not(doc), repr(transparent))] #[cfg_attr(not(doc), repr(transparent))]
pub struct Path { pub struct Path {
inner: OsStr, inner: OsStr,