Warning
This post was published 36 days ago. The information described in this article may have changed.
Hi everyone,
I was reading RFC 1758 regarding the #[repr(transparent)]
attribute and came across this section:
As a matter of optimisation, eligible #[repr(Rust)] structs behave as if they were #[repr(transparent)] but as an implementation detail that can't be relied upon by users.
struct ImplicitlyTransparentWrapper(f64);
#[repr(C)]
struct BogusRepr {
// While ImplicitlyTransparentWrapper implicitly has the same representation
// as f64, this will fail to compile because ImplicitlyTransparentWrapper
// has no explicit transparent or C representation.
wrapper: ImplicitlyTransparentWrapper,
}
The RFC says this code should fail to compile because ImplicitlyTransparentWrapper
does not have an explicit #[repr(transparent)]
or #[repr(C)]
.
However, when I tried this exact code on stable Rust, it does compile without any issues.
Questions:
Would appreciate any clarification or pointers to newer discussions or RFCs that reflect the current behavior. Thanks!
4 posts - 3 participants
🏷️ rust_feed