Skip to content

Commit 56f472d

Browse files
committed
Eliminate use of #[cfg_attr(not(doc), repr(...))]
1 parent ee8c9d3 commit 56f472d

File tree

6 files changed

+24
-32
lines changed

6 files changed

+24
-32
lines changed

library/core/src/error.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ where
509509
/// ```
510510
///
511511
#[unstable(feature = "error_generic_member_access", issue = "99301")]
512-
#[cfg_attr(not(doc), repr(transparent))] // work around https://github.com/rust-lang/rust/issues/90435
512+
#[repr(transparent)]
513513
pub struct Request<'a>(dyn Erased<'a> + 'a);
514514

515515
impl<'a> Request<'a> {

library/core/src/ffi/c_str.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,9 @@ use crate::str;
8383
#[rustc_has_incoherent_inherent_impls]
8484
#[lang = "CStr"]
8585
// `fn from` in `impl From<&CStr> for Box<CStr>` current implementation relies
86-
// on `CStr` being layout-compatible with `[u8]`.
87-
// However, `CStr` layout is considered an implementation detail and must not be relied upon. We
88-
// want `repr(transparent)` but we don't want it to show up in rustdoc, so we hide it under
89-
// `cfg(doc)`. This is an ad-hoc implementation of attribute privacy.
90-
#[cfg_attr(not(doc), repr(transparent))]
86+
// on `CStr` being layout-compatible with `[u8]`. However, `CStr` layout is
87+
// considered an implementation detail and must not be relied upon.
88+
#[repr(transparent)]
9189
pub struct CStr {
9290
// FIXME: this should not be represented with a DST slice but rather with
9391
// just a raw `c_char` along with some form of marker to make

library/core/src/ffi/mod.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ mod c_long_definition {
204204
// be UB.
205205
#[doc = include_str!("c_void.md")]
206206
#[lang = "c_void"]
207-
#[cfg_attr(not(doc), repr(u8))] // work around https://github.com/rust-lang/rust/issues/90435
207+
#[repr(u8)]
208208
#[stable(feature = "core_c_void", since = "1.30.0")]
209209
pub enum c_void {
210210
#[unstable(
@@ -245,7 +245,7 @@ impl fmt::Debug for c_void {
245245
target_os = "uefi",
246246
windows,
247247
))]
248-
#[cfg_attr(not(doc), repr(transparent))] // work around https://github.com/rust-lang/rust/issues/90435
248+
#[repr(transparent)]
249249
#[unstable(
250250
feature = "c_variadic",
251251
reason = "the `c_variadic` feature has not been properly tested on \
@@ -297,7 +297,7 @@ impl<'f> fmt::Debug for VaListImpl<'f> {
297297
not(target_os = "uefi"),
298298
not(windows),
299299
))]
300-
#[cfg_attr(not(doc), repr(C))] // work around https://github.com/rust-lang/rust/issues/66401
300+
#[repr(C)]
301301
#[derive(Debug)]
302302
#[unstable(
303303
feature = "c_variadic",
@@ -317,7 +317,7 @@ pub struct VaListImpl<'f> {
317317

318318
/// PowerPC ABI implementation of a `va_list`.
319319
#[cfg(all(target_arch = "powerpc", not(target_os = "uefi"), not(windows)))]
320-
#[cfg_attr(not(doc), repr(C))] // work around https://github.com/rust-lang/rust/issues/66401
320+
#[repr(C)]
321321
#[derive(Debug)]
322322
#[unstable(
323323
feature = "c_variadic",
@@ -337,7 +337,7 @@ pub struct VaListImpl<'f> {
337337

338338
/// s390x ABI implementation of a `va_list`.
339339
#[cfg(target_arch = "s390x")]
340-
#[cfg_attr(not(doc), repr(C))] // work around https://github.com/rust-lang/rust/issues/66401
340+
#[repr(C)]
341341
#[derive(Debug)]
342342
#[unstable(
343343
feature = "c_variadic",
@@ -356,7 +356,7 @@ pub struct VaListImpl<'f> {
356356

357357
/// x86_64 ABI implementation of a `va_list`.
358358
#[cfg(all(target_arch = "x86_64", not(target_os = "uefi"), not(windows)))]
359-
#[cfg_attr(not(doc), repr(C))] // work around https://github.com/rust-lang/rust/issues/66401
359+
#[repr(C)]
360360
#[derive(Debug)]
361361
#[unstable(
362362
feature = "c_variadic",
@@ -374,7 +374,7 @@ pub struct VaListImpl<'f> {
374374
}
375375

376376
/// A wrapper for a `va_list`
377-
#[cfg_attr(not(doc), repr(transparent))] // work around https://github.com/rust-lang/rust/issues/90435
377+
#[repr(transparent)]
378378
#[derive(Debug)]
379379
#[unstable(
380380
feature = "c_variadic",

library/core/src/task/wake.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ impl fmt::Debug for Context<'_> {
233233
///
234234
/// [`Future::poll()`]: core::future::Future::poll
235235
/// [`Poll::Pending`]: core::task::Poll::Pending
236-
#[cfg_attr(not(doc), repr(transparent))] // work around https://github.com/rust-lang/rust/issues/66401
236+
#[repr(transparent)]
237237
#[stable(feature = "futures_api", since = "1.36.0")]
238238
pub struct Waker {
239239
waker: RawWaker,

library/std/src/ffi/os_str.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,10 @@ impl crate::sealed::Sealed for OsString {}
110110
/// [conversions]: super#conversions
111111
#[cfg_attr(not(test), rustc_diagnostic_item = "OsStr")]
112112
#[stable(feature = "rust1", since = "1.0.0")]
113-
// `OsStr::from_inner` current implementation relies
114-
// on `OsStr` being layout-compatible with `Slice`.
115-
// However, `OsStr` layout is considered an implementation detail and must not be relied upon. We
116-
// want `repr(transparent)` but we don't want it to show up in rustdoc, so we hide it under
117-
// `cfg(doc)`. This is an ad-hoc implementation of attribute privacy.
118-
#[cfg_attr(not(doc), repr(transparent))]
113+
// `OsStr::from_inner` current implementation relies on `OsStr` being layout-
114+
// compatible with `Slice`. However, `OsStr` layout is considered an
115+
// implementation detail and must not be relied upon.
116+
#[repr(transparent)]
119117
pub struct OsStr {
120118
inner: Slice,
121119
}

library/std/src/path.rs

+8-12
Original file line numberDiff line numberDiff line change
@@ -1158,12 +1158,10 @@ impl FusedIterator for Ancestors<'_> {}
11581158
/// Which method works best depends on what kind of situation you're in.
11591159
#[cfg_attr(not(test), rustc_diagnostic_item = "PathBuf")]
11601160
#[stable(feature = "rust1", since = "1.0.0")]
1161-
// `PathBuf::as_mut_vec` current implementation relies
1162-
// on `PathBuf` being layout-compatible with `Vec<u8>`.
1163-
// However, `PathBuf` layout is considered an implementation detail and must not be relied upon. We
1164-
// want `repr(transparent)` but we don't want it to show up in rustdoc, so we hide it under
1165-
// `cfg(doc)`. This is an ad-hoc implementation of attribute privacy.
1166-
#[cfg_attr(not(doc), repr(transparent))]
1161+
// `PathBuf::as_mut_vec` current implementation relies on `PathBuf` being
1162+
// layout-compatible with `Vec<u8>`. However, `PathBuf` layout is considered an
1163+
// implementation detail and must not be relied upon.
1164+
#[repr(transparent)]
11671165
pub struct PathBuf {
11681166
inner: OsString,
11691167
}
@@ -1983,12 +1981,10 @@ impl AsRef<OsStr> for PathBuf {
19831981
/// ```
19841982
#[cfg_attr(not(test), rustc_diagnostic_item = "Path")]
19851983
#[stable(feature = "rust1", since = "1.0.0")]
1986-
// `Path::new` current implementation relies
1987-
// on `Path` being layout-compatible with `OsStr`.
1988-
// However, `Path` layout is considered an implementation detail and must not be relied upon. We
1989-
// want `repr(transparent)` but we don't want it to show up in rustdoc, so we hide it under
1990-
// `cfg(doc)`. This is an ad-hoc implementation of attribute privacy.
1991-
#[cfg_attr(not(doc), repr(transparent))]
1984+
// `Path::new` current implementation relies on `Path` being layout-compatible
1985+
// with `OsStr`. However, `Path` layout is considered an implementation detail
1986+
// and must not be relied upon.
1987+
#[repr(transparent)]
19921988
pub struct Path {
19931989
inner: OsStr,
19941990
}

0 commit comments

Comments
 (0)