-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Description
Currently, repr(transparent)
ignores all 1-ZST, including uninhabited types. Together with the ABI promise we are making for repr(transparent)
, that means we cannot in any way exploit the uninhabitedness of a type for the purpose of the function call ABI -- which has led to #135802; we had to actually pessimize the ABI for functions returning things like (i32, !)
to account for this. (Cc @zachs18)
@rust-lang/lang is that a deliberate feature of repr(transparent)
? It seems more like an accident to me.
However, it is an accident that is non-trivial to fix, since it turns out hyper
contains a type like this:
#[repr(transparent)]
struct Neutered<B> {
_inner: B,
impossible: Impossible,
}
enum Impossible {}
Under a more reasonable set of rules for repr(transparent)
that does not just ignore uninhabited 1-ZST, this type would be rejected. @seanmonstar @nox is there any particular reason why this type is repr(transparent)
? It is still uninhabited, making it insta-UB to create an element, even by transmutation from B
.
A crater run has been queued in #147589.