Skip to content

enum variant values must be cast to their own type #13902

Closed
@metajack

Description

@metajack

The following program does not compile:

#![allow(non_camel_case_types)]

static JSVAL_TAG_CLEAR: u32 = 0xFFFFFF80;
static JSVAL_TYPE_INT32: u8 = 0x01;
static JSVAL_TYPE_UNDEFINED: u8 = 0x02;
#[repr(u32)]
enum ValueTag {
    JSVAL_TAG_INT32 = JSVAL_TAG_CLEAR | (JSVAL_TYPE_INT32 as u32),
    JSVAL_TAG_UNDEFINED = JSVAL_TAG_CLEAR | (JSVAL_TYPE_UNDEFINED as u32),
}

fn main() {
    let _ = JSVAL_TAG_INT32;
}

If you add as u32 after JSVAL_TAG_CLEAR then it compiles fine. I assume this is interacting with repr such that it doesn't know the real type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions