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 - task 'rustc' panicked at 'struct variant kind unexpected in get_item_val' #19452

Closed
daramos opened this issue Dec 2, 2014 · 0 comments
Closed
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@daramos
Copy link
Contributor

daramos commented Dec 2, 2014

While trying something new I ran across this compiler panic. I was able to create the following minimal test case:

enum TestEnum {
    NonValue,
    Value {val1: uint}
}

fn main() {
    let mut tmp = TestEnum::NonValue;
    tmp = TestEnum::Value
}
rustc 0.13.0-nightly (fac5a0767 2014-11-26 22:37:06 +0000)
binary: rustc
commit-hash: fac5a07679cac21a580badc84b755b8df0f975cf
commit-date: 2014-11-26 22:37:06 +0000
host: x86_64-unknown-linux-gnu
release: 0.13.0-nightly
task 'rustc' panicked at 'struct variant kind unexpected in get_item_val', /home/rustbuild/src/rust-buildbot/slave/nightly-linux/build/src/librustc_trans/trans/base.rs:2858

stack backtrace:
   1:     0x7f011935c3b0 - rt::backtrace::imp::write::h753be74b825f61ed19x
   2:     0x7f011935f480 - failure::on_fail::h7418e5cabf6c549ekCy
   3:     0x7f0118fb5320 - unwind::begin_unwind_inner::h21b15480bba8536c0Qc
   4:     0x7f01197c5b60 - unwind::begin_unwind::h2131595671141106281
   5:     0x7f0119801d70 - trans::base::get_item_val::h07c1542a8cc17e2c7Gv
   6:     0x7f011983b100 - trans::callee::trans_fn_ref_with_substs::h6e3a101edcd458250Ig
   7:     0x7f0119838f70 - trans::callee::trans_fn_ref::hdcbcf0a826d12eabYwg
   8:     0x7f011985cab0 - trans::expr::trans_def::h6b990a449f274953wdj
   9:     0x7f01198531a0 - trans::expr::trans_unadjusted::h0241b45889b366e7iJi
  10:     0x7f0119812a00 - trans::expr::trans::hc5e4f3c1c8708fa0dUh
  11:     0x7f0119857a20 - trans::expr::trans_rvalue_stmt_unadjusted::hb710868ffa4bd9bfBhj
  12:     0x7f01198110d0 - trans::expr::trans_into::hfd54d60c945a0fc8hQh
  13:     0x7f01198116a0 - trans::controlflow::trans_block::he010926f525ec62dk2d
  14:     0x7f01198c47e0 - trans::base::trans_closure::h8f4dac4e13bf4972tDu
  15:     0x7f01198036a0 - trans::base::trans_fn::h0a1b95c8abed202bjPu
  16:     0x7f0119800690 - trans::base::trans_item::h4f3b35bce9ae51243av
  17:     0x7f01198c9160 - trans::base::trans_mod::h18114d50e28ae38eygv
  18:     0x7f01198cff80 - trans::base::trans_crate::hc608c93243bdc3cfn9v
  19:     0x7f011997cad0 - driver::driver::phase_4_translate_to_llvm::ha275ee9ba36f38d9PvS
  20:     0x7f011996a2f0 - driver::driver::compile_input::h342f6a27db36679d12R
  21:     0x7f01199ee280 - driver::run_compiler::h817060b002a7c16090T
  22:     0x7f01199ee170 - driver::run::closure.59904
  23:     0x7f01197f5d10 - task::TaskBuilder::try_future::closure.39020
  24:     0x7f011932d010 - task::TaskBuilder::spawn_internal::closure.30320
  25:     0x7f0118fb3100 - task::Task::spawn::closure.5727
  26:     0x7f011900d470 - rust_try_inner
  27:     0x7f011900d460 - rust_try
  28:     0x7f0118fb31e0 - unwind::try::h75fe9090402d7736lFc
  29:     0x7f0118fb2fa0 - task::Task::run::h1f2cd4b02103da7aeOb
  30:     0x7f0118fb2b90 - task::Task::spawn::closure.5703
  31:     0x7f0118fb45e0 - thread::thread_start::h60b7b4aa191da867h6b
  32:     0x7f0113d1b0c0 - start_thread
  33:     0x7f0118c7a2d9 - __clone
  34:                0x0 - <unknown>

This compiles just fine:

enum TestEnum {
    NonValue,
    Value {val1: uint}
}

fn main() {
    let mut tmp = TestEnum::NonValue;
    tmp = TestEnum::Value{ val1: 1 }
}
@sfackler sfackler added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Dec 2, 2014
brson added a commit to brson/rust that referenced this issue Dec 12, 2014
Unlike a tuple variant constructor which can be called as a function, a struct variant constructor is not a function, so cannot be called.

If the user tries to assign the constructor to a variable, an ICE occurs, because there is no way to use it later. So we should stop the constructor from being used like that.

A similar mechanism already exists for a normal struct, as it prohibits a struct from being resolved. This commit does the same for a struct variant.

This commit also includes some changes to the existing tests.

Fixes rust-lang#19452.
bors added a commit that referenced this issue Dec 14, 2014
…r=alexcrichton

Unlike a tuple variant constructor which can be called as a function, a struct variant constructor is not a function, so cannot be called.

If the user tries to assign the constructor to a variable, an ICE occurs, because there is no way to use it later. So we should stop the constructor from being used like that.

A similar mechanism already exists for a normal struct, as it prohibits a struct from being resolved. This commit does the same for a struct variant.

This commit also includes some changes to the existing tests.

Fixes #19452.
@bors bors closed this as completed in cfee5b7 Dec 14, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants