Skip to content

Error with cast in enum definition. #23304

@Ms2ger

Description

@Ms2ger

The following code hits an error:

#![allow(dead_code)]

#[repr(u32)]
enum ValueTag {
    INT32                = 0x1FFF0u32 | (0x01 as u32),
    X,
}

#[repr(u64)]
enum ValueShiftedTag {
    INT32        = ValueTag::INT32 as u64,
    X,
}

fn main() {
    println!("{}", ValueTag::INT32 as u32);
}
/tmp/a.rs:7:42: 7:53 error: constant evaluation error: can't cast this type [E0080]
/tmp/a.rs:7     INT32                = 0x1FFF0u32 | (0x01 as u32),
                                                     ^~~~~~~~~~~

Note that the error doesn't reproduce without the ValueShiftedTag definition.

This blocks the current rust upgrade for Servo.

CC @eddyb.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions