Skip to content

ICE when compiling a trait #39520

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
ulysseB opened this issue Feb 4, 2017 · 3 comments
Closed

ICE when compiling a trait #39520

ulysseB opened this issue Feb 4, 2017 · 3 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@ulysseB
Copy link

ulysseB commented Feb 4, 2017

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
@ulysseB
Copy link
Author

ulysseB commented Feb 4, 2017

This issue might be related to #39292. In both cases, the problem seems to be a missing implementation for a method in a trait. However, #39292 fails at runtime while here the compiler crashes at compile time.

@sfackler sfackler added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Feb 4, 2017
@Aaron1011
Copy link
Member

This appears to be fixed in the latest nightly.

@arielb1
Copy link
Contributor

arielb1 commented Mar 27, 2017

Looks like a dupe of #39292.

@arielb1 arielb1 closed this as completed Mar 27, 2017
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

No branches or pull requests

4 participants