Skip to content

ICE when compiling a trait #39520

Closed
Closed
@ulysseB

Description

@ulysseB

The following code produces an internal compiler error:

trait Foo<'a, T: 'a> {
    fn print(&'a self) { println!("foo"); }
}

impl<'a> Foo<'a, &'a ()> for () { }

trait Bar: for<'a> Foo<'a, &'a ()> { }

impl Bar for () {}

fn main() {
    (&() as &Bar).print(); // Segfault
}

The output of cargo build is:

error: internal compiler error: /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/librustc_trans/common.rs:486: Encountered error `Unimplemented` selecting `Binder(<() as Foo<&()>>)` during trans

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 'Box<Any>', /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/librustc_errors/lib.rs:382
stack backtrace:
   1:     0x7fea4fb7787c - std::sys::imp::backtrace::tracing::imp::write::h9c41d2f69e5caabf
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:42
   2:     0x7fea4fb85d7e - std::panicking::default_hook::{{closure}}::hcc803c8663cda123
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/panicking.rs:351
   3:     0x7fea4fb85923 - std::panicking::default_hook::hd5bda4e453dfb4be
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/panicking.rs:361
   4:     0x7fea4fb8621b - std::panicking::rust_panic_with_hook::hffbc74969c7b5d87
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/panicking.rs:555
   5:     0x7fea4f1f06f8 - std::panicking::begin_panic::h009a4e2d350d221e
   6:     0x7fea4f20df45 - rustc::session::opt_span_bug_fmt::{{closure}}::h69afe0ff24f7f15e
   7:     0x7fea4f20dd5a - rustc::session::span_bug_fmt::h818e09b82b402713
   8:     0x7fea4f280557 - rustc_trans::common::fulfill_obligation::{{closure}}::{{closure}}::h4c05a39904720b74
   9:     0x7fea4f27c7dc - rustc_trans::common::fulfill_obligation::h5088fb0747e0ff32
  10:     0x7fea4f278f6b - rustc_trans::collector::do_static_dispatch::h3b495a9f26fe2f54
  11:     0x7fea4f277f43 - <rustc_trans::collector::MirNeighborCollector<'a, 'tcx> as rustc::mir::visit::Visitor<'tcx>>::visit_rvalue::h3fa769f346707134
  12:     0x7fea4f208ba9 - rustc::mir::visit::Visitor::visit_mir::h30efb03b6342ed30
  13:     0x7fea4f27a9f9 - rustc_trans::collector::collect_neighbours::h0a4e0493af367107
  14:     0x7fea4f276b92 - rustc_trans::collector::collect_items_rec::h0eba73626eef3df5
  15:     0x7fea4f2670b8 - rustc_trans::base::collect_and_partition_translation_items::{{closure}}::h145240e8a158bc9c
  16:     0x7fea4f26245f - rustc_trans::base::collect_and_partition_translation_items::hb5755540f2e117c8
  17:     0x7fea4f2554f2 - rustc_trans::base::trans_crate::h496d157cb52a4b02
  18:     0x7fea4ff39740 - rustc_driver::driver::phase_4_translate_to_llvm::h106eb073675c3bee
  19:     0x7fea4ff0b242 - rustc_driver::driver::compile_input::{{closure}}::heec508e3b0737586
  20:     0x7fea4ff2cbd1 - rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}::haa13372f770e9055
  21:     0x7fea4fe8fcb9 - rustc::ty::context::TyCtxt::create_and_enter::h6acd1d75709e85e8
  22:     0x7fea4ff091f0 - rustc_driver::driver::compile_input::h44853ffed84a12cb
  23:     0x7fea4ff4e634 - rustc_driver::run_compiler::hdc4bb0fcf7d0917a
  24:     0x7fea4fe5abfb - std::panicking::try::do_call::h84a15e0d2b943318
  25:     0x7fea4fb8f05a - __rust_maybe_catch_panic
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libpanic_unwind/lib.rs:98
  26:     0x7fea4fe82e52 - <F as alloc::boxed::FnBox<A>>::call_box::h61c78220cad685ea
  27:     0x7fea4fb84bd4 - std::sys::imp::thread::Thread::new::thread_start::h76badbf9b0ecaf58
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/liballoc/boxed.rs:615
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/sys_common/thread.rs:21
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/sys/unix/thread.rs:84
  28:     0x7fea47963453 - start_thread
  29:     0x7fea4f8477de - __GI___clone
  30:                0x0 - <unknown>

The compiler version is:

rustc 1.16.0-nightly (eedaa94e3 2017-02-02)
binary: rustc
commit-hash: eedaa94e330094a84f4df9aa52949515327f8e80
commit-date: 2017-02-02
host: x86_64-unknown-linux-gnu
release: 1.16.0-nightly
LLVM version: 3.9

Metadata

Metadata

Assignees

No one assigned

    Labels

    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