Skip to content

ICE: "index is not an integer-constant expression" using enum as array index. #23513

Closed
@theemathas

Description

@theemathas

Code:

enum E { A, }

const C: [u32; 1] = [1];

fn main() {
    let a = C[E::A as usize];
}

playpen

Error message:

<anon>:6:9: 6:10 warning: unused variable: `a`, #[warn(unused_variables)] on by default
<anon>:6     let a = C[E::A as usize];
                 ^
<anon>:6:15: 6:28 error: internal compiler error: index is not an integer-constant expression
<anon>:6     let a = C[E::A as usize];
                       ^~~~~~~~~~~~~
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'Box<Any>', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libsyntax/diagnostic.rs:130

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions