Skip to content

ICE: Encountered error Unimplemented ... (trait objects & associated type bounds) #26406

Closed
@jonm13

Description

I've got an ICE when trying to use associated type bounds with a trait object.

Here's the full code:

struct S1;
struct S2;

trait Foo<T:?Sized> {
    fn foo_method(&self, &T);
}

trait Bar {
    fn bar_method(&self) -> Self::A;
    type A:Foo<Self>;
}

impl Foo<S1> for S2 {
    fn foo_method(&self, _other:&S1) {
        println!("S1");
    }
}

impl Bar for S1 {
    fn bar_method(&self) -> S2 { S2 }
    type A = S2;
}

fn play<T:?Sized+Bar>(arg:&T) {
    arg.bar_method().foo_method(arg);
}

fn main() {
    play(&S1 as &Bar<A=S2>);
}

I did expect some error to occur when trying to pass a trait object to play because of the reference to Self in the bound A:Foo<Self> in trait Bar (perhaps Bar shouldn't be object-safe?).

I got the following ICE:

rust-compiler-error.rs:25:5: 25:37 error: internal compiler error: Encountered error `Unimplemented` selecting `Binder(Foo<Bar<A=S2>>)` during trans
rust-compiler-error.rs:25     arg.bar_method().foo_method(arg);
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

thread 'rustc' panicked at 'Box<Any>', /Users/rustbuild/src/rust-buildbot/slave/stable-dist-rustc-mac/build/src/libsyntax/diagnostic.rs:149

stack backtrace:
   1:        0x108243e7f - sys::backtrace::write::h7807ec07859fb503t1r
   2:        0x10824c4b2 - panicking::on_panic::ha0ed2b9b562a7f9ctZv
   3:        0x108208e35 - rt::unwind::begin_unwind_inner::hbfb8d99cb52be7a1cHv
   4:        0x1079e343e - rt::unwind::begin_unwind::h14482673826369992638
   5:        0x1079e33ca - diagnostic::SpanHandler::span_bug::ha80d5103c6dc346fEqB
   6:        0x10565606c - session::Session::span_bug::hcde8c0eff4a188a1ODq
   7:        0x105336d36 - trans::common::fulfill_obligation::h980785cbb616e61caPr
   8:        0x1053202ba - trans::meth::trans_method_callee::ha28edc2f1b2a8fd0uzI
   9:        0x10531d51c - trans::callee::trans_call_inner::h14698893033598190724
  10:        0x1053865b9 - trans::expr::trans_rvalue_dps_unadjusted::hb679c5947dd23995C5A
  11:        0x105358ac7 - trans::expr::trans_into::hbb46bcc22ed210c3X6z
  12:        0x1053585b1 - trans::controlflow::trans_stmt_semi::h9f4c7751e520c73141u
  13:        0x1052d7e78 - trans::controlflow::trans_block::hdf65bd89d5d3fafb02u
  14:        0x1052d6b55 - trans::base::trans_closure::h41cb738fdafdcb78LCh
  15:        0x1052d87ee - trans::base::trans_fn::hbccbee21cfd23d2atNh
  16:        0x10531abb9 - trans::monomorphize::monomorphic_fn::hb0b9d13fdbb393b9tCJ
  17:        0x10530a537 - trans::callee::trans_fn_ref_with_substs::h65df1c1a3f07d589UEn
  18:        0x105308fd2 - trans::callee::trans_fn_ref::h9d943fd61b436f60Zsn
  19:        0x105306065 - trans::callee::trans::hf3e13a5b6c64ff57jin
  20:        0x10531b86d - trans::callee::trans_call_inner::h8933410478418265344
  21:        0x10538644f - trans::expr::trans_rvalue_dps_unadjusted::hb679c5947dd23995C5A
  22:        0x105358ac7 - trans::expr::trans_into::hbb46bcc22ed210c3X6z
  23:        0x1053585b1 - trans::controlflow::trans_stmt_semi::h9f4c7751e520c73141u
  24:        0x1052d7e78 - trans::controlflow::trans_block::hdf65bd89d5d3fafb02u
  25:        0x1052d6b55 - trans::base::trans_closure::h41cb738fdafdcb78LCh
  26:        0x1052d87ee - trans::base::trans_fn::hbccbee21cfd23d2atNh
  27:        0x1052dbd58 - trans::base::trans_item::hae807f8e0cfc6665Fbi
  28:        0x1052eaba2 - trans::base::trans_crate::h2f3789dec4e60e5cF0i
  29:        0x104d7c27e - driver::phase_4_translate_to_llvm::h561d8971e5091942hOa
  30:        0x104d54204 - driver::compile_input::hf0607b3d1fd498bcQba
  31:        0x104e1c5a3 - run_compiler::he7a5311c755081d7z4b
  32:        0x104e1a0ca - boxed::F.FnBox<A>::call_box::h5234503372052129763
  33:        0x104e19567 - rt::unwind::try::try_fn::h4031265711883657142
  34:        0x1082cd508 - rust_try_inner
  35:        0x1082cd4f5 - rust_try
  36:        0x104e19840 - boxed::F.FnBox<A>::call_box::h1044299548107784679
  37:        0x10824affd - sys::thread::create::thread_start::ha3be9b31a8775143L4u
  38:     0x7fff95439267 - _pthread_body
  39:     0x7fff954391e4 - _pthread_start
$ rustc --version --verbose
rustc 1.0.0 (a59de37e9 2015-05-13) (built 2015-05-14)
binary: rustc
commit-hash: a59de37e99060162a2674e3ff45409ac73595c0e
commit-date: 2015-05-13
build-date: 2015-05-14
host: x86_64-apple-darwin
release: 1.0.0

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