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 on impossible trait object/associated type #27874

Closed
talchas opened this issue Aug 17, 2015 · 4 comments
Closed

ICE on impossible trait object/associated type #27874

talchas opened this issue Aug 17, 2015 · 4 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@talchas
Copy link

talchas commented Aug 17, 2015

trait Hack: std::ops::Add<Self, Output = Self> + Copy {}
fn takes_hack(x: &Hack<Output=i32>) {}```
(which can't work of course)

Gives:
thread 'rustc' panicked at 'assertion failed: !ty.needs_infer()', ../src/librustc_typeck/lib.rs:152
on playpen's nightly and on an older nightly:
   1:     0x7f2a73cac30e - sys::backtrace::write::h1e294cdf8b83f011srs
   2:     0x7f2a73cb44d4 - panicking::on_panic::h759b2622c5bddde1mdx
   3:     0x7f2a73c76ade - rt::unwind::begin_unwind_inner::hdb2ee52cd09f11c10Sw
   4:     0x7f2a73415651 - rt::unwind::begin_unwind::h16407102452406535252
   5:     0x7f2a73519747 - collect::convert_item::hee80771e2831a06bVHx
   6:     0x7f2a735164c7 - collect::collect_item_types::hb25670e75e1ace20iPw
   7:     0x7f2a735636c9 - check_crate::h699f9ca48d981e0dRWC
   8:     0x7f2a74211cc9 - driver::phase_3_run_analysis_passes::closure.15891
   9:     0x7f2a7421060b - middle::ty::ctxt<'tcx>::create_and_enter::h14877326799551551326
  10:     0x7f2a7420b5b1 - driver::phase_3_run_analysis_passes::h13027946853248993312
  11:     0x7f2a741ea80c - driver::compile_input::h1bb41626855952a5Tba
  12:     0x7f2a742d0e83 - run_compiler::hed8febc643a5bd02A7b
  13:     0x7f2a742ce85e - boxed::F.FnBox<A>::call_box::h3262743521461286850
  14:     0x7f2a742ce0a9 - rt::unwind::try::try_fn::h13012207966773460524
  15:     0x7f2a73d2f9d8 - rust_try_inner
  16:     0x7f2a73d2f9c5 - rust_try
  17:     0x7f2a73c9f647 - rt::unwind::try::inner_try::hcf9d4b2ce436da47TOw
  18:     0x7f2a742ce2bb - boxed::F.FnBox<A>::call_box::h5485760352730305604
  19:     0x7f2a73cb3131 - sys::thread::Thread::new::thread_start::h6bca3390d26c61e4GYv
@arielb1
Copy link
Contributor

arielb1 commented Aug 20, 2015

mini:

trait Foo<T:?Sized> {type S;}
trait Hack: Foo<Self> {}
fn takes_hack(x: &Hack<S=()>) {}
fn main() {}

This is non-object-safe, but the crash occurs in collect - needs to be prohibited earlier.

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

@arielb1's test case no longer ICEs:

foo.rs:3:19: 3:29 error: the trait `Hack` cannot be made into an object [E0038]
foo.rs:3 fn takes_hack(x: &Hack<S=()>) {}
                           ^~~~~~~~~~
foo.rs:3:19: 3:29 help: run `rustc --explain E0038` to see a detailed explanation
foo.rs:3:19: 3:29 note: the trait cannot use `Self` as a type parameter in the supertrait listing

@arielb1
Copy link
Contributor

arielb1 commented Oct 24, 2015

duplicate of #28576 (is there a version of github search that doesn't suck?).

@arielb1 arielb1 closed this as completed Oct 24, 2015
@arielb1
Copy link
Contributor

arielb1 commented Oct 24, 2015

I searched for needs_infer when I fixed #28576, but github search ignored me.

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