Skip to content

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

@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.

Activity

added
A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html
on Dec 19, 2017
eddyb

eddyb commented on Dec 19, 2017

@eddyb
Member

cc @arielb1 @nikomatsakis Did anything change in pattern-matching between stable and beta?

K900

K900 commented on Dec 19, 2017

@K900
Author

I'm bisecting as I'm writing this, but it's taking a while on my dual-core laptop :(

eddyb

eddyb commented on Dec 19, 2017

@eddyb
Member
added this to the 1.23 milestone on Dec 19, 2017
Mark-Simulacrum

Mark-Simulacrum commented on Dec 19, 2017

@Mark-Simulacrum
Member

cc @est31 -- Is there a chance you could run bisect? We should really get playground to be capable of doing it...

est31

est31 commented on Dec 20, 2017

@est31
Member

@Mark-Simulacrum not today, sorry. Maybe on friday...

added a commit that references this issue on Dec 20, 2017
8dfc47a
Deewiant

Deewiant commented on Dec 20, 2017

@Deewiant
Contributor

I decided to bisect this myself and found 5b1cc1d (or #45821 as a whole) to be the cause, and created #46877 to fix it.

added a commit that references this issue on Dec 21, 2017
b7b52cc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @jdm@eddyb@K900@Deewiant@Mark-Simulacrum

        Issue actions

          ICE with match on non-const functions in constant definitions · Issue #46843 · rust-lang/rust