Do not consider uninhabited 1-ZST "trivial" for the purpose of repr(transparent)?
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
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 https://github.com/rust-lang/rust/issues/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 https://github.com/rust-lang/rust/pull/147589.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the repr(transparent) ABI promise and the interaction with uninhabited 1-ZST types described in this issue. Inspect hyper's src/proto/h2/mod.rs Neutered type, then read issue #135802 and the crater run in PR #147589. Done means establishing whether the behavior is deliberate and determining compatible rules or changes for affected code.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100