Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upTracking issue for RFC 1758: Specify `repr(transparent)` #43036
Comments
aturon
added
B-RFC-approved
T-lang
labels
Jul 3, 2017
aturon
changed the title
Tracking issue for RFC 1758: Specify
Tracking issue for RFC 1758: Specify `repr(transparent)`
Jul 3, 2017
This comment has been minimized.
This comment has been minimized.
|
Mentoring instructions unavailable. This is sadly not that easy, as we have too much code that still relies on assumptions that such types do not exist. I have an in-progress branch which requires implementing the necessary support for "newtype unpacking" but no time frame for completion. |
This comment has been minimized.
This comment has been minimized.
|
Is making types like |
This comment has been minimized.
This comment has been minimized.
|
@RalfJung For a change at that level, a PR approved by the libs team suffices. |
dtolnay
referenced this issue
Jul 10, 2017
Closed
c_void should not be an enum with public variants #48
SimonSapin
referenced this issue
Jul 27, 2017
Closed
Tracking issue for `NonZero`/`Unique`/`Shared` stabilization #27730
fitzgen
referenced this issue
Jul 27, 2017
Open
Tracking rustc bugs/features/RFCs that affect bindgen #849
Mark-Simulacrum
added
the
C-tracking-issue
label
Jul 27, 2017
emilio
referenced this issue
Sep 2, 2017
Open
Bitfield enums in return position violate the Linux 32-bit ABI #941
This was referenced Sep 25, 2017
emilio
added a commit
to emilio/clang-sys
that referenced
this issue
Oct 9, 2017
emilio
referenced this issue
Oct 9, 2017
Closed
lib: Stop using bitflags to declare FFI definitions. #66
KyleMayes
added a commit
to KyleMayes/clang-sys
that referenced
this issue
Oct 11, 2017
This comment has been minimized.
This comment has been minimized.
|
The RFC makes contradictory statements about the interaction with
#[repr(transparent, align = "128")]
struct BogusAlign(f64);
#[repr(transparent, packed)]
struct BogusPacked(f64);... while the Detailed Design section says:
#[repr(transparent, align = "128")]
struct OverAligned(f64); // Behaves as a bare f64 with 128 bits alignment.
#[repr(C, transparent)]
struct BogusRepr(f64); // Nonsensical, repr cannot be C and transparent.AFAICT the RFC initially prohibited repr(transparent, align), then in the discussion some people asked for it to be allowed, but later the rationale for that was called into question and there was no consensus or (explicit) decision. So it's hard to see which alternative was intended to be the final state by the RFC author and the lang team. |
This comment has been minimized.
This comment has been minimized.
|
I'd disallow it since it significantly complicates the implementation IMO. Is there any motivation for allowing the combination? |
This comment has been minimized.
This comment has been minimized.
|
Discussion is mostly rust-lang/rfcs#1758 (comment) plus the immediate replies. The motivation is not immediately clear to me, just that a nested wrapper type with |
This comment has been minimized.
This comment has been minimized.
|
@nox tells me on IRC they have no use case for it. Let's amend the RFC to consistently reject repr(transparent, align). If someone does find a use case, they can deal with the implementation effort and amend the RFC again. |
This comment has been minimized.
This comment has been minimized.
briansmith
commented
Dec 16, 2017
•
|
Sorry, it's been forever since we had that conversation. Maybe I'm overlooking something, but I think #[repr(transparent, align=16)]
struct Aes256Key([u8; 32]);
#[repr(transparent, align=16)]
struct AesNonce([u8; 16]);
// Keep this in sync with the C definition in aes.h
#[repr(C)]
struct Aes256Context {
key: Aes256Key,
...
nonce: AesNonce,
...
}
extern aes256Encrypt(context: &mut Aes256Context, ...);I'm not sure how one would express this otherwise. |
This comment has been minimized.
This comment has been minimized.
|
Is there any ABI where you need EDIT: Also, are you ever passing or returning |
This comment has been minimized.
This comment has been minimized.
briansmith
commented
Dec 17, 2017
•
Consider: typedef uint8_t AES256Key[32];
typedef uint8_t AES128Key[16];
typedef uint8_t AESNonce[16];
struct Aes256Context {
alignas(16) AES256Key key;
alignas(16) AES256Nonce nonce;
};Notice in particular that in this C code
Is that true? Maybe I'm misunderstanding the purpose of struct Outer1 {
struct Wrapper value1;
struct Wrapper value2;
};
struct Wrapper {
uint8_t value[12];
};
struct Outer2 {
uint8_t value1[12];
uint8_t value2[12];
};Are these structures guaranteed, by C, to have the same memory layout? I don't remember the details but I think the answer is "no". And that's why
I think a struct with one field, like |
This comment has been minimized.
This comment has been minimized.
|
@briansmith That would imply EDIT: also, it looks like the correct translation of the C code would be |
rfcbot
removed
the
proposed-final-comment-period
label
May 23, 2018
rfcbot
added
the
finished-final-comment-period
label
Jun 2, 2018
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Jun 2, 2018
|
The final comment period, with a disposition to merge, as per the review above, is now complete. |
rfcbot
removed
the
final-comment-period
label
Jun 2, 2018
SimonSapin
referenced this issue
Jun 6, 2018
Merged
Implement rfc 1789: Conversions from `&mut T` to `&Cell<T>` #50494
SimonSapin
added a commit
to SimonSapin/reference
that referenced
this issue
Jun 6, 2018
SimonSapin
referenced this issue
Jun 6, 2018
Closed
Import #[repr(transparent)] docs from the Unstable book #353
SimonSapin
added a commit
to SimonSapin/rust
that referenced
this issue
Jun 6, 2018
SimonSapin
referenced this issue
Jun 6, 2018
Merged
Add #[repr(transparent)] to some libcore types #51395
This comment has been minimized.
This comment has been minimized.
|
Stabilization PR: #51395 |
SimonSapin
added a commit
to SimonSapin/rust
that referenced
this issue
Jun 6, 2018
SimonSapin
added a commit
to SimonSapin/rust
that referenced
this issue
Jun 8, 2018
SimonSapin
added a commit
to SimonSapin/rust
that referenced
this issue
Jun 8, 2018
SimonSapin
added a commit
to SimonSapin/rust
that referenced
this issue
Jun 9, 2018
SimonSapin
added a commit
to SimonSapin/rust
that referenced
this issue
Jun 12, 2018
bors
added a commit
that referenced
this issue
Jun 14, 2018
bors
added a commit
that referenced
this issue
Jun 15, 2018
bors
added a commit
that referenced
this issue
Jun 16, 2018
bors
added a commit
that referenced
this issue
Jun 16, 2018
This comment has been minimized.
This comment has been minimized.
|
Oops, this should have been closed by #51562. |
SimonSapin
closed this
Jun 26, 2018
bors
added a commit
that referenced
this issue
Jul 3, 2018
bors
added a commit
that referenced
this issue
Jul 4, 2018
This comment has been minimized.
This comment has been minimized.
|
Could I ask here for some eyes on a suggestion to add |
aturon commentedJul 3, 2017
•
edited by SimonSapin
RFC
This is a tracking issue for the RFC "Specify
repr(transparent)" (rust-lang/rfcs#1758).Steps: