Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
K900 opened this issue Dec 19, 2017 · 6 comments
Closed

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

K900 opened this issue Dec 19, 2017 · 6 comments
Labels
A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html regression-from-stable-to-beta Performance or correctness regression from stable to beta.
Milestone

Comments

@K900
Copy link

K900 commented Dec 19, 2017

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.

@jdm jdm added the regression-from-stable-to-beta Performance or correctness regression from stable to beta. label Dec 19, 2017
@eddyb eddyb added the A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html label Dec 19, 2017
@eddyb
Copy link
Member

eddyb commented Dec 19, 2017

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

@K900
Copy link
Author

K900 commented Dec 19, 2017

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

@eddyb
Copy link
Member

eddyb commented Dec 19, 2017

cc @Mark-Simulacrum

@Mark-Simulacrum Mark-Simulacrum added this to the 1.23 milestone Dec 19, 2017
@Mark-Simulacrum
Copy link
Member

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

@est31
Copy link
Member

est31 commented Dec 20, 2017

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

Deewiant added a commit to Deewiant/rust that referenced this issue Dec 20, 2017
Fixes rust-lang#46843.

rust-lang#45821 added unreachable blocks in matches, which were terminated in
construct_fn but not in construct_const, causing a panic due to "no
terminator on block" when constants involved matching on enums.

The "unimplemented expression type" error may go away in the future, the
key is that we see the E0015 about using a non-const function and then
don't ICE.
@Deewiant
Copy link
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.

bors added a commit that referenced this issue Dec 21, 2017
MIR: terminate unreachable blocks in construct_const

Fixes #46843.

#45821 added unreachable blocks in matches, which were terminated in
construct_fn but not in construct_const, causing a panic due to "no
terminator on block" when constants involved matching on enums.

The "unimplemented expression type" error may go away in the future, the
key is that we see the E0015 about using a non-const function and then
don't ICE.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html regression-from-stable-to-beta Performance or correctness regression from stable to beta.
Projects
None yet
Development

No branches or pull requests

6 participants