Skip to content

ICE with match on non-const functions in constant definitions #46843

Closed
@K900

Description

@K900
enum Thing { This, That }

fn non_const() -> Thing {
    Thing::This
}

pub const Q: i32 = match non_const() {
    Thing::This => 1,
    Thing::That => 0
};
error: internal compiler error: /checkout/src/librustc_mir/build/mod.rs:534: no terminator on block 10

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: rustc 1.24.0-nightly (0077d128d 2017-12-14) running on x86_64-unknown-linux-gnu

thread 'rustc' panicked at 'Box<Any>', /checkout/src/librustc_errors/lib.rs:448:8
note: Run with `RUST_BACKTRACE=1` for a backtrace.

(playground)

This ICEs on nightly/beta, but produces a correct error on stable.

Originally reported on Reddit here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlregression-from-stable-to-betaPerformance or correctness regression from stable to beta.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions