Skip to content
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

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

Closed
Tracked by #27579
jonm13 opened this issue Jun 18, 2015 · 5 comments
Closed
Tracked by #27579
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@jonm13
Copy link

jonm13 commented Jun 18, 2015

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
@arielb1
Copy link
Contributor

arielb1 commented Jun 18, 2015

This is caused by missing wf-checking for associated types. cc #25388

@jdm jdm added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Jun 21, 2015
@arielb1
Copy link
Contributor

arielb1 commented Aug 14, 2015

Fixed by #27641.

@arielb1 arielb1 closed this as completed Aug 14, 2015
@nikomatsakis
Copy link
Contributor

In fact, an ICE still occurs. Reopening.

@apasel422
Copy link
Contributor

Triage: Still an issue.

@Mark-Simulacrum
Copy link
Member

No longer ICEs:

    error[E0038]: the trait `Bar` cannot be made into an object
  --> ./test.rs:29:17
   |
29 |     play(&S1 as &Bar<A=S2>);
   |                 ^^^^^^^^^^ the trait `Bar` cannot be made into an object
   |
   = note: the trait cannot use `Self` as a type parameter in the supertraits or where-clauses

error[E0277]: the trait bound `Bar<A=S2>: Bar` is not satisfied
  --> ./test.rs:29:5
   |
29 |     play(&S1 as &Bar<A=S2>);
   |     ^^^^ the trait `Bar` is not implemented for `Bar<A=S2>`
   |
   = note: required by `play`

error[E0038]: the trait `Bar` cannot be made into an object
  --> ./test.rs:29:5
   |
29 |     play(&S1 as &Bar<A=S2>);
   |     ^^^^ the trait `Bar` cannot be made into an object
   |
   = note: the trait cannot use `Self` as a type parameter in the supertraits or where-clauses

error[E0038]: the trait `Bar` cannot be made into an object
  --> ./test.rs:29:10
   |
29 |     play(&S1 as &Bar<A=S2>);
   |          ^^^ the trait `Bar` cannot be made into an object
   |
   = note: the trait cannot use `Self` as a type parameter in the supertraits or where-clauses
   = note: required because of the requirements on the impl of `std::ops::CoerceUnsized<&Bar<A=S2>>` for `&S1`

error: aborting due to 4 previous errors

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

6 participants