Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Techcable opened this issue Aug 6, 2021 · 0 comments

Comments

@Techcable
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant