Skip to content

ICE when using associated constants #27249

Closed
@istankovic

Description

@istankovic

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>

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-associated-itemsArea: Associated items (types, constants & functions)I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions