From bbe4da839fa931505da7ef6c9e4da1a116de9181 Mon Sep 17 00:00:00 2001 From: Pavel Grigorenko Date: Mon, 22 Jul 2024 00:59:58 +0300 Subject: [PATCH] Fix some `#[cfg_attr(not(doc), repr(..))]` Now that #90435 seems to have been resolved. --- core/src/error.rs | 2 +- core/src/ffi/c_str.rs | 2 +- core/src/ffi/mod.rs | 2 +- core/src/ffi/va_list.rs | 4 ++-- core/src/task/wake.rs | 4 ++-- std/src/ffi/os_str.rs | 6 ++---- std/src/path.rs | 6 ++---- 7 files changed, 11 insertions(+), 15 deletions(-) diff --git a/core/src/error.rs b/core/src/error.rs index ca8983d4cbcfe..19b7bb44f855a 100644 --- a/core/src/error.rs +++ b/core/src/error.rs @@ -506,7 +506,7 @@ where /// ``` /// #[unstable(feature = "error_generic_member_access", issue = "99301")] -#[cfg_attr(not(doc), repr(transparent))] // work around https://github.com/rust-lang/rust/issues/90435 +#[repr(transparent)] pub struct Request<'a>(Tagged + 'a>); impl<'a> Request<'a> { diff --git a/core/src/ffi/c_str.rs b/core/src/ffi/c_str.rs index 563f0a324e3f1..c9111254082da 100644 --- a/core/src/ffi/c_str.rs +++ b/core/src/ffi/c_str.rs @@ -103,7 +103,7 @@ use crate::str; // 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))] +#[repr(transparent)] #[allow(clippy::derived_hash_with_manual_eq)] pub struct CStr { // FIXME: this should not be represented with a DST slice but rather with diff --git a/core/src/ffi/mod.rs b/core/src/ffi/mod.rs index 88adc378477fd..93426b90c706a 100644 --- a/core/src/ffi/mod.rs +++ b/core/src/ffi/mod.rs @@ -191,7 +191,7 @@ mod c_long_definition { // be UB. #[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 +#[cfg_attr(not(doc), repr(u8))] // An implementation detail we don't want to show up in rustdoc #[stable(feature = "core_c_void", since = "1.30.0")] pub enum c_void { #[unstable( diff --git a/core/src/ffi/va_list.rs b/core/src/ffi/va_list.rs index 6a2e8b67d0c2a..f4c746225dc03 100644 --- a/core/src/ffi/va_list.rs +++ b/core/src/ffi/va_list.rs @@ -23,7 +23,7 @@ use crate::ops::{Deref, DerefMut}; target_os = "uefi", windows, ))] -#[cfg_attr(not(doc), repr(transparent))] // work around https://github.com/rust-lang/rust/issues/90435 +#[repr(transparent)] #[lang = "va_list"] pub struct VaListImpl<'f> { ptr: *mut c_void, @@ -115,7 +115,7 @@ pub struct VaListImpl<'f> { } /// A wrapper for a `va_list` -#[cfg_attr(not(doc), repr(transparent))] // work around https://github.com/rust-lang/rust/issues/90435 +#[repr(transparent)] #[derive(Debug)] pub struct VaList<'a, 'f: 'a> { #[cfg(any( diff --git a/core/src/task/wake.rs b/core/src/task/wake.rs index 86a965f68e085..9d74e64ed6372 100644 --- a/core/src/task/wake.rs +++ b/core/src/task/wake.rs @@ -429,7 +429,7 @@ impl<'a> ContextBuilder<'a> { /// [`Future::poll()`]: core::future::Future::poll /// [`Poll::Pending`]: core::task::Poll::Pending /// [`Wake`]: ../../alloc/task/trait.Wake.html -#[cfg_attr(not(doc), repr(transparent))] // work around https://github.com/rust-lang/rust/issues/66401 +#[repr(transparent)] #[stable(feature = "futures_api", since = "1.36.0")] pub struct Waker { waker: RawWaker, @@ -695,7 +695,7 @@ impl fmt::Debug for Waker { /// [`Poll::Pending`]: core::task::Poll::Pending /// [`local_waker`]: core::task::Context::local_waker #[unstable(feature = "local_waker", issue = "118959")] -#[cfg_attr(not(doc), repr(transparent))] // work around https://github.com/rust-lang/rust/issues/66401 +#[repr(transparent)] pub struct LocalWaker { waker: RawWaker, } diff --git a/std/src/ffi/os_str.rs b/std/src/ffi/os_str.rs index f9dba08da4c3c..0fb3964c9a9b4 100644 --- a/std/src/ffi/os_str.rs +++ b/std/src/ffi/os_str.rs @@ -115,10 +115,8 @@ impl crate::sealed::Sealed for OsString {} #[stable(feature = "rust1", since = "1.0.0")] // `OsStr::from_inner` current implementation relies // on `OsStr` being layout-compatible with `Slice`. -// However, `OsStr` 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))] +// However, `OsStr` layout is considered an implementation detail and must not be relied upon. +#[repr(transparent)] pub struct OsStr { inner: Slice, } diff --git a/std/src/path.rs b/std/src/path.rs index d5121a554bf6c..0cef862549c8a 100644 --- a/std/src/path.rs +++ b/std/src/path.rs @@ -2079,10 +2079,8 @@ impl AsRef for PathBuf { #[stable(feature = "rust1", since = "1.0.0")] // `Path::new` current implementation relies // on `Path` being layout-compatible with `OsStr`. -// However, `Path` 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))] +// However, `Path` layout is considered an implementation detail and must not be relied upon. +#[repr(transparent)] pub struct Path { inner: OsStr, }