Skip to content

C-like enums should generate TypeInfo::CStyleEnum instead of TypeInfo::Integer #2

@Techcable

Description

@Techcable

Right now, the TypeInfo doesn't accurately reflect the static type of C-style enums.

In Rust, (unlike C), enums can only accept a restricted subset of values.
For example, given the enum definition:

#[repr(u32)]
enum Test {
    One = 1,
    Two = 2,
    Three = 4,
}
/*
 * Rust: UNDEFINED BEHAVIOR
 * C: This is fine
 */
std::mem::transmute::<u32, Test>(12)

Right now, Test::TYPE_INFO == u32::TYPE_INFO as if we were using the C representation. This is misleading,
and should be fixed to use the new CStyleEnumDef struct that I just added.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions