Skip to content

ICE in constant evaluation with function call #29587

Closed
@eefriedman

Description

@eefriedman
fn f(x: usize) -> usize {
    x
}

const Y: usize = f(2);

fn main() {
    let z = [0; Y];
}
error: internal compiler error: unexpected panic
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 'assertion failed: `(left == right)` (left: `NotConst`, right: `Const`)', ../src/librustc/middle/const_eval.rs:1067

Initially reported at https://github.com/rust-lang/rust/pull/26848/files#r43700207 .

CC @oli-obk .

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