Skip to content

How transitive is repr(transparent)? #486

@Manishearth

Description

@Manishearth

Context: hyperium/hyper#3500

repr(transparent) makes types have the same representation/ABI. Does it have the same effect on generic types containing it?

For example, in the following case:

enum Generic<T> {
   Type(T),
   TwoType(T, T),
   String(String),
   Nothing
}

#[repr(transparent)]
struct Wrapper<T>(T);

is it safe to transmute between Generic<T> and Generic<Wrapper<T>>? Do they have the same ABI? I'm thinking about things like -Zrandomize-layout.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions