Skip to content

Commit 7a87c2f

Browse files
authored
Rollup merge of #107680 - dtolnay:docrepr, r=Amanieu
Hide repr attribute from doc of types without guaranteed repr Rustdoc has an undesirable behavior of blindly copying `repr` into the documentation of structs and enums, even when there is no particular repr that the type guarantees to its users. This is a source of confusion for standard library users who assume the fact that a repr is documented means it must be something the standard library promises they can rely on (in transmutes, or FFI). Some issues on the topic of rustdoc's incorrect handling of `repr`: - rust-lang/rust#66401 - rust-lang/rust#90435 In places, the standard library currently works around this confusing rustdoc behavior by just omitting `repr(transparent)` altogether even where it should be required if equivalent code were being written outside of the standard library. See #61969. IMO that is even more confusing, even for standard library maintainers — see rust-lang/rust#105018 (comment). It's also not something that works for other reprs like `C` or `u8` which cannot just be omitted even in standard library code. This PR tries a different approach for some types that are being currently incorrectly documented with a repr. > **Warning** > This PR does not imply that every type that still has a `repr` attribute in its docs after this PR is now public for users to rely on. This PR only tries to reduce harm from this longstanding rustdoc issue.
2 parents 2584e27 + bcb5126 commit 7a87c2f

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

crates/core_simd/src/masks.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl_element! { isize }
8888
/// The layout of this type is unspecified, and may change between platforms
8989
/// and/or Rust versions, and code should not assume that it is equivalent to
9090
/// `[T; LANES]`.
91-
#[repr(transparent)]
91+
#[cfg_attr(not(doc), repr(transparent))] // work around https://github.com/rust-lang/rust/issues/90435
9292
pub struct Mask<T, const LANES: usize>(mask_impl::Mask<T, LANES>)
9393
where
9494
T: MaskElement,

0 commit comments

Comments
 (0)