Skip to content

Associated types: ICE "type_of with ty_projection" #20368

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
kinghajj opened this issue Dec 31, 2014 · 1 comment · Fixed by #20706
Closed

Associated types: ICE "type_of with ty_projection" #20368

kinghajj opened this issue Dec 31, 2014 · 1 comment · Fixed by #20706
Labels
A-associated-items Area: Associated items (types, constants & functions) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@kinghajj
Copy link

After #20307 was merged, I tried using associated types again to improve an API, but ran into an ICE demonstrated by the following example.

#![feature(associated_types)]

trait Foo {
  fn foo(&self) -> ();
}

trait Bar {
  type F: Foo;
}

struct Wat<B: Bar> {
  fs: Vec<B::F>,
}

impl<B: Bar> Wat<B> {
  fn new() -> Self {
    Wat { fs: Vec::new() }
  }

  fn wat(&mut self) -> () {
    Foo::foo(&self.fs.pop().unwrap());
  }
}

struct FooImpl;

impl Foo for FooImpl {
  fn foo(&self) -> () {}
}

struct BarImpl;

impl Bar for BarImpl {
  type F = FooImpl;
}

fn main() {
  // error is caused by this line.
  let wat: Wat<BarImpl> = Wat::new();
}

Error:

error: internal compiler error: type_of with ty_projection
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'Box<Any>', /Users/samuel/Documents/rust/src/libsyntax/diagnostic.rs:182

stack backtrace:
   1:        0x10b98aa25 - sys::backtrace::write::h79fcf57f48f2accbUpt
   2:        0x10b9af473 - failure::on_fail::he313666202ab06e0wwz
   3:        0x10b9156aa - rt::unwind::begin_unwind_inner::h3818eca49d000e060dz
   4:        0x10988fe47 - rt::unwind::begin_unwind::h2232683046508229913
   5:        0x1098907b8 - diagnostic::Handler::bug::hd878cdd91e904135bVF
   6:        0x108edc1e8 - session::Session::bug::he3e7f8e3682f0beezyp
   7:        0x1084d0001 - trans::type_of::type_of::h9197635c60619429njp
   8:        0x1084d020f - trans::type_of::type_of::h9197635c60619429njp
   9:        0x1085f5c15 - vec::Vec<T>.FromIterator<T>::from_iter::h6585550067129994724
  10:        0x1084d04c3 - trans::type_of::type_of::h9197635c60619429njp
  11:        0x1084cf3ac - trans::type_of::type_of::h9197635c60619429njp
  12:        0x1085f5c15 - vec::Vec<T>.FromIterator<T>::from_iter::h6585550067129994724
  13:        0x1084d04c3 - trans::type_of::type_of::h9197635c60619429njp
  14:        0x1084cf3ac - trans::type_of::type_of::h9197635c60619429njp
  15:        0x1085f5c15 - vec::Vec<T>.FromIterator<T>::from_iter::h6585550067129994724
  16:        0x1084d04c3 - trans::type_of::type_of::h9197635c60619429njp
  17:        0x1084cf3ac - trans::type_of::type_of::h9197635c60619429njp
  18:        0x1084d8eed - trans::base::alloc_ty::h0ff116b4545bfc9eFFt
  19:        0x1085be404 - trans::_match::mk_binding_alloca::h1489438822966140848
  20:        0x1084c99e3 - trans::base::init_local::h78d0086b1f8238539qt
  21:        0x1084cae95 - trans::controlflow::trans_block::h2f26f7b25eb8f55a2ae
  22:        0x1085883a4 - trans::base::trans_closure::hd27e32dcce03144cKju
  23:        0x1084bac1b - trans::base::trans_fn::hb6a8bb6b558798cazuu
  24:        0x1084b6276 - trans::base::trans_item::h823c6709f851fa543Ru
  25:        0x10858f1f8 - trans::base::trans_crate::he3d01922f8b5bab14Ov
  26:        0x1082ebd0e - driver::phase_4_translate_to_llvm::hc27e2b2792fb5383eFa
  27:        0x1082ce0b1 - driver::compile_input::hf6a1e42e515c971bwba
  28:        0x1083ff393 - thunk::F.Invoke<A, R>::invoke::h1106905942537841072
  29:        0x1083fc4f0 - rt::unwind::try::try_fn::h16870325584336102008
  30:        0x10ba19649 - rust_try_inner
  31:        0x10ba19636 - rust_try
  32:        0x1083fcc36 - thunk::F.Invoke<A, R>::invoke::h8218093585600920335
  33:        0x10b99bd84 - sys::thread::thread_start::hccba841055eeb8d6Dfw
  34:     0x7fff8d7932fc - _pthread_body
  35:     0x7fff8d793279 - _pthread_body
@huonw huonw added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ A-associated-items Area: Associated items (types, constants & functions) labels Dec 31, 2014
@nikomatsakis
Copy link
Contributor

Almost certainly a dup of #20470

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-associated-items Area: Associated items (types, constants & functions) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants