Skip to content

ICE when using associated constants #27249

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

Closed
istankovic opened this issue Jul 23, 2015 · 3 comments
Closed

ICE when using associated constants #27249

istankovic opened this issue Jul 23, 2015 · 3 comments
Labels
A-associated-items Area: Associated items (types, constants & functions) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@istankovic
Copy link
Contributor

The following code results in a compiler panic:

#![feature(associated_consts)]

struct Foo;

impl Foo {
    pub const FOO: u32 = 3;
}

fn main() {
    Foo::FOO;
}

Backtrace:

$ RUST_BACKTRACE=1 rustc a.rs
a.rs:11:5: 11:14 warning: path statement with no effect, #[warn(path_statements)] on by default
a.rs:11     Foo::FOO;
            ^~~~~~~~~
error: internal compiler error: unimplemented unsupported def type in trans_local_var: DefAssociatedConst(DefId { krate: 0, node: 8 }Foo::FOO, FromImpl(DefId { krate: 0, node: 7 }Foo))
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
thread 'rustc' panicked at 'Box<Any>', ../src/libsyntax/diagnostic.rs:253

stack backtrace:
   1:     0x7fc0f3cdd48e - sys::backtrace::write::he30188f6ff1a3730Zws
   2:     0x7fc0f3ce57b5 - panicking::on_panic::h8c19c2151488a3e02lx
   3:     0x7fc0f3ca69ce - rt::unwind::begin_unwind_inner::h906f5dda0b9cb210F1w
   4:     0x7fc0f10ff7ac - rt::unwind::begin_unwind::h17351444284051756501
   5:     0x7fc0f110112b - diagnostic::Handler::bug::hec7f5d0eda19cfe2GfB
   6:     0x7fc0f11011f4 - diagnostic::Handler::unimpl::hcc62fb5d263b6ea4jgB
   7:     0x7fc0f1f64828 - session::Session::unimpl::h10fa5bb20285cdcdV9s
   8:     0x7fc0f2b41429 - trans::expr::trans_local_var::h7fe5e56fcd0ca544TkC
   9:     0x7fc0f2b972bf - trans::expr::trans_def::h0279a013eb707adfVTB
  10:     0x7fc0f2b8ec5c - trans::expr::trans_unadjusted::h00ea76411cccd23euwB
  11:     0x7fc0f2b68480 - trans::expr::trans_into::hf6a23a4a270aa1abQSA
  12:     0x7fc0f2b67e66 - trans::controlflow::trans_stmt_semi::h02750060a9151ab03Hv
  13:     0x7fc0f2af8e6a - trans::controlflow::trans_block::h46396bcaf59ccb9dZIv
  14:     0x7fc0f2af7f00 - trans::base::trans_closure::h704961d2a61157bfjxi
  15:     0x7fc0f2af97d8 - trans::base::trans_fn::ha77c10d30b3c98f66Gi
  16:     0x7fc0f2afc898 - trans::base::trans_item::h36e5a8cde2d0f72bh6i
  17:     0x7fc0f2b0980c - trans::base::trans_crate::h6ad67f6175cd0ca0eUj
  18:     0x7fc0f4251d14 - driver::phase_4_translate_to_llvm::hc1bdc8e7ff6c7c145Oa
  19:     0x7fc0f424c355 - driver::phase_3_run_analysis_passes::closure.16405
  20:     0x7fc0f42465ab - middle::ty::ctxt<'tcx>::create_and_enter::h8352421393399420656
  21:     0x7fc0f4241581 - driver::phase_3_run_analysis_passes::h10686122484823704679
  22:     0x7fc0f4225760 - driver::compile_input::h6526e31cf4171f0aTba
  23:     0x7fc0f4309673 - run_compiler::hc96ca56d6cc7d3a9A7b
  24:     0x7fc0f43070ee - boxed::F.FnBox<A>::call_box::h9423186817318254201
  25:     0x7fc0f4306a19 - rt::unwind::try::try_fn::h13811593359414256150
  26:     0x7fc0f3ce527f - __rust_try_inner
  27:     0x7fc0f3ce52ba - __rust_try
  28:     0x7fc0f3cd0907 - rt::unwind::try::inner_try::h6341c86a1012d543yXw
  29:     0x7fc0f4306c38 - boxed::F.FnBox<A>::call_box::h18302996666967064961
  30:     0x7fc0f3ce4381 - sys::thread::Thread::new::thread_start::h7602653539d5ded2D6v
  31:     0x7fc0ed919353 - start_thread
  32:     0x7fc0f3943bfc - __clone
  33:                0x0 - <unknown>
@apasel422
Copy link
Contributor

For what it's worth, this also causes an ICE:

const FOO: u32 = 5;

fn main() {
    FOO;
}
bar.rs:4:5: 4:9 warning: path statement with no effect, #[warn(path_statements)] on by default
bar.rs:4     BAZ;
             ^~~~
bar.rs:4:5: 4:8 error: internal compiler error: constant expression should not reach expr::trans_def
bar.rs:4     BAZ;
             ^~~
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
thread 'rustc' panicked at 'Box<Any>', ../src/libsyntax/diagnostic.rs:176

stack backtrace:
   1:     0x7fdcb574a48e - sys::backtrace::write::h9d7a90b82951696dZws
   2:     0x7fdcb5752795 - panicking::on_panic::h84e509cf0bec31052lx
   3:     0x7fdcb57139ce - rt::unwind::begin_unwind_inner::h2e32ca1bf051967dF1w
   4:     0x7fdcb2b427cc - rt::unwind::begin_unwind::h16335744487247261469
   5:     0x7fdcb2b4276b - diagnostic::SpanHandler::span_bug::h1300244878ddb7aeb9A
   6:     0x7fdcb3601ca8 - session::Session::span_bug::h93d3986bee8b5267mat
   7:     0x7fdcb45dc7f3 - trans::expr::trans_def::h0cc06b0217f1e27c1TB
   8:     0x7fdcb45d3f7c - trans::expr::trans_unadjusted::h231a5476fd4b3a6eAwB
   9:     0x7fdcb45ad720 - trans::expr::trans_into::h202510f14f809442WSA
  10:     0x7fdcb45ad106 - trans::controlflow::trans_stmt_semi::h14851b10f841f7db9Hv
  11:     0x7fdcb453e0ca - trans::controlflow::trans_block::h7b997b267421ef305Iv
  12:     0x7fdcb453d160 - trans::base::trans_closure::h6c1a660000c76f88ixi
  13:     0x7fdcb453ea38 - trans::base::trans_fn::h040bb295d71555c25Gi
  14:     0x7fdcb4541ae8 - trans::base::trans_item::h07c7a6fa646583f7g6i
  15:     0x7fdcb454ea6c - trans::base::trans_crate::h34f1d7ba225f9cf7dUj
  16:     0x7fdcb5cbec04 - driver::phase_4_translate_to_llvm::hf081ebedb088ee245Oa
  17:     0x7fdcb5cb9245 - driver::phase_3_run_analysis_passes::closure.16406
  18:     0x7fdcb5cb349b - middle::ty::ctxt<'tcx>::create_and_enter::h5957637365875790786
  19:     0x7fdcb5cae471 - driver::phase_3_run_analysis_passes::h8973828644736070193
  20:     0x7fdcb5c92630 - driver::compile_input::h90abd5c73807fe0dTba
  21:     0x7fdcb5d76853 - run_compiler::he6382510493c3ff3A7b
  22:     0x7fdcb5d742ce - boxed::F.FnBox<A>::call_box::h2004289560739142696
  23:     0x7fdcb5d73bf9 - rt::unwind::try::try_fn::h2041046763977595402
  24:     0x7fdcb575225f - __rust_try_inner
  25:     0x7fdcb575229a - __rust_try
  26:     0x7fdcb573d907 - rt::unwind::try::inner_try::h9bf0939b00d7b9e6yXw
  27:     0x7fdcb5d73e18 - boxed::F.FnBox<A>::call_box::h13582013758951967072
  28:     0x7fdcb5751361 - sys::thread::Thread::new::thread_start::hd79e684f6fbf95bfD6v
  29:     0x7fdcaf35b6a9 - start_thread
  30:     0x7fdcb53a7eec - clone
  31:                0x0 - <unknown>

@steveklabnik steveklabnik added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Jul 29, 2015
@nagisa nagisa added the A-associated-items Area: Associated items (types, constants & functions) label May 16, 2016
@seanmonstar
Copy link
Contributor

Current ICE is:

thread 'rustc' panicked at 'assertion failed: type_is_zero_size(bcx.ccx(), bcx.tcx().node_id_to_type(expr.id))', ../src/librustc_trans/expr.rs:158

This isn't specific to associated items. All sized constants trip this assert.

@steveklabnik
Copy link
Member

This ICE seems to be fixed on

rustc 1.12.0-nightly (b30eff7ba 2016-08-05)

I have a hunch that this is due to MIR being turned on, though I'm not sure. Please let me know if this still ICEs for you, but closing for now 🎊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-associated-items Area: Associated items (types, constants & functions) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

5 participants