Skip to content

Commit f07f949

Browse files
author
Robin Kruppe
committed
Amend RFC 1758 (repr(transparent)) w.r.t. repr(align)
The RFC made contradictory statements on whether repr(align(N)) can be combined with repr(transparent). [Discussion on the tracking issue][discuss] did not find a good reason to support it, so this commit makes the RFC internally consistent by prohibiting align(N) on transparent structs. [discuss]: rust-lang/rust#43036 (comment)
1 parent b38be11 commit f07f949

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

text/1758-repr-transparent.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,14 @@ have the same representation as their underlying types.
117117

118118
[RFC 1649]: https://github.com/rust-lang/rfcs/pull/1649
119119

120-
This new representation cannot be used with any other representation attribute
121-
but alignment, to be able to specify a transparent wrapper with additional
122-
alignment constraints:
120+
This new representation cannot be used with any other representation attribute:
123121

124122
```rust
125123
#[repr(transparent, align = "128")]
126-
struct OverAligned(f64); // Behaves as a bare f64 with 128 bits alignment.
124+
struct BogusAlign(f64); // Error, must be aligned like the underlying type.
127125

128126
#[repr(C, transparent)]
129-
struct BogusRepr(f64); // Nonsensical, repr cannot be C and transparent.
127+
struct BogusRepr(f64); // Error, repr cannot be C and transparent.
130128
```
131129

132130
As a matter of optimisation, eligible `#[repr(Rust)]` structs behave as if

0 commit comments

Comments
 (0)