Enum rustc::middle::trans::adt::Repr[src]

pub enum Repr {
    CEnum(IntType, Disr, Disr),
    Univariant(Struct, bool),
    General(IntType, Vec<Struct>),
    RawNullablePointer {
        pub nndiscr: Disr,
        pub nnty: t,
        pub nullfields: Vec<t>,
    },
    StructWrappedNullablePointer {
        pub nonnull: Struct,
        pub nndiscr: Disr,
        pub ptrfield: uint,
        pub nullfields: Vec<t>,
    },
}

Representations.

Variants

CEnum

C-like enums; basically an int.

Univariant

Single-case variants, and structs/tuples/records.

Structs with destructors need a dynamic destroyedness flag to avoid running the destructor too many times; this is included in the Struct if present.

General

General-case enums: for each case there is a struct, and they all start with a field for the discriminant.

RawNullablePointer

Two cases distinguished by a nullable pointer: the case with discriminant nndiscr must have single field which is known to be nonnull due to its type. The other case is known to be zero sized. Hence we represent the enum as simply a nullable pointer: if not null it indicates the nndiscr variant, otherwise it indicates the other case.

Fields

nndiscr
nnty
nullfields
StructWrappedNullablePointer

Two cases distinguished by a nullable pointer: the case with discriminant nndiscr is represented by the struct nonnull, where the ptrfieldth field is known to be nonnull due to its type; if that field is null, then it represents the other case, which is inhabited by at most one value (and all other fields are undefined/unused).

For example, std::option::Option instantiated at a safe pointer type is represented such that None is a null pointer and Some is the identity function.

Fields

nonnull
nndiscr
ptrfield
nullfields