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

Const fn causes ICE in a pattern #30117

Closed
arielb1 opened this issue Nov 30, 2015 · 1 comment
Closed

Const fn causes ICE in a pattern #30117

arielb1 opened this issue Nov 30, 2015 · 1 comment
Labels
A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@arielb1
Copy link
Contributor

arielb1 commented Nov 30, 2015

STR

#![feature(const_fn)]
const fn four() -> u32 { 4 }
const FOUR: u32 = four();
fn main() { match 4 { FOUR => {}, _ => unreachable!() }}

at the current version of play.rust-lang.org

ICE

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 'internal error: entered unreachable code', ../src/librustc/middle/const_eval.rs:327

playpen: application terminated with error code 101

@arielb1 arielb1 added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ A-const-fn labels Nov 30, 2015
@oli-obk
Copy link
Contributor

oli-obk commented Dec 1, 2015

The reason this is happening is because the code thinks four is an enum variant or a tuple struct.

The code around this is somewhat redundant and would probably better be solved by making enum variants const evaluable and adding a function that translates ConstVals to Constructor

@bors bors closed this as completed in d23800f Dec 16, 2015
@RalfJung RalfJung added the A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) label Dec 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

3 participants