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 with associated type on trait #24810

Closed
mdup opened this issue Apr 25, 2015 · 4 comments
Closed

ICE with associated type on trait #24810

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

Comments

@mdup
Copy link

mdup commented Apr 25, 2015

Given the following code,

use std::ops::Add;

trait T: Add<Output=Self> {
}

impl T<Output=T> {
}

fn main() {
}

the compiler crashes:

$ RUST_BACKTRACE=1 rustc main.rs
main.rs:6:15: 6:16 error: the value of the associated type `Output` (from the trait `core::ops::Add`) must be specified [E0191]
main.rs:6 impl T<Output=T> {
                        ^
error: internal compiler error: unexpected panic
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 'assertion failed: !ty::type_needs_infer(ty)', /Users/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-mac/build/src/librustc_typeck/lib.rs:148

stack backtrace:
   1:        0x103d6cb3f - sys::backtrace::write::he7c1ee6a91037116KVr
   2:        0x103d75242 - panicking::on_panic::h95811d48f94bff2aNVv
   3:        0x103d31985 - rt::unwind::begin_unwind_inner::h83dd7700bec4d3dcwDv
   4:        0x100b0b8af - rt::unwind::begin_unwind::h5521202385013033086
   5:        0x100c3058e - collect::convert_item::he430b0ba35372b84KGx
   6:        0x100c7ba06 - check_crate::closure.38384
   7:        0x100c7997a - check_crate::h38598962c6951e9d2EC
   8:        0x1004d4f72 - driver::phase_3_run_analysis_passes::h4345ea303ca2819ctGa
   9:        0x1004b6b18 - driver::compile_input::h83758d277994a32eQba
  10:        0x10057bb43 - run_compiler::h2639405527e4221cF4b
  11:        0x1005792aa - boxed::F.FnBox<A>::call_box::h1823104088724806648
  12:        0x1005787f7 - rt::unwind::try::try_fn::h7700810389900064321
  13:        0x103df7618 - rust_try_inner
  14:        0x103df7605 - rust_try
  15:        0x100578ace - boxed::F.FnBox<A>::call_box::h1089084376626579945
  16:        0x103d73c3d - sys::thread::Thread::new::thread_start::he43a1bd6638c19advYu
  17:     0x7fff930b9898 - _pthread_body
  18:     0x7fff930b9729 - _pthread_start

$ rustc --version
rustc 1.1.0-nightly (21f278a68 2015-04-23) (built 2015-04-24)

As a sidenote, I've played with it and was not able to find the correct syntax. The goal is to have a trait requires all implementers be able to add to themselves.

@mdup
Copy link
Author

mdup commented Apr 25, 2015

I believe I might have finally got the syntax right; the error message disappears. However, the ICE remains.

use std::ops::Add;

trait T: Add {
}

impl<X: T> T<Output=X> {
}

fn main() {
}

@huonw huonw added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Apr 25, 2015
@joliv
Copy link
Contributor

joliv commented Jun 11, 2015

Not sure if this is relevant, but I got the same error in a similar situation running cargo build on this code:

extern crate num;

use num::Num;

fn foo (x: Num<Output=::std::num::ParseIntError>) {}

Backtrace follows.

unexpected panic
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
thread 'rustc' panicked at 'assertion failed: !ty::type_needs_infer(ty)', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/librustc_typeck/lib.rs:147

stack backtrace:
   1: 0xb732a077 - sys::backtrace::write::h6952996a21c47c07ads
   2: 0xb7333434 - panicking::on_panic::hd35d988ee3a5c2f1ZXw
   3: 0xb72ef773 - rt::unwind::begin_unwind_inner::he8bdefc833f13e3eJDw
   4: 0xb6cfbdc2 - rt::unwind::begin_unwind::h16236413390050183289
   5: 0xb6e1f99f - collect::convert_item::h9d94d3548d25d26ffSx
   6: 0xb6e1c7ef - collect::collect_item_types::h4bbb002ff41bd8d7cZw
   7: 0xb6e70912 - check_crate::h049a1ef5eff22056w8C
   8: 0xb7679d02 - driver::phase_3_run_analysis_passes::h41e2f1d518a20260GGa
   9: 0xb76584f6 - driver::compile_input::hb258e9d05d852669Qba
  10: 0xb77278fd - run_compiler::hb667b3f9ee661164n6b
  11: 0xb7724c6e - boxed::F.FnBox<A>::call_box::h4284501152216545036
  12: 0xb7724441 - rt::unwind::try::try_fn::h3762789488623463148
  13: 0xb73beb8a - rust_try_inner
  14: 0xb73beb63 - rust_try
  15: 0xb731cd7c - rt::unwind::try::inner_try::h778b76ec9ae57243Czw
  16: 0xb7724668 - boxed::F.FnBox<A>::call_box::h8463684128851076905
  17: 0xb7332054 - sys::thread::Thread::new::thread_start::h5f3e9b55c97be469OJv
  18: 0xb31c81c2 - start_thread
  19: 0xb717ee8d - __clone
  20:        0x0 - <unknown>
$ rustc --version
rustc 1.2.0-nightly (8f9f2fe97 2015-06-07)

@nham
Copy link
Contributor

nham commented May 17, 2016

None of the examples above ICE for me. Using rustc 1.8.0 (db2939409 2016-04-11), the first results in:

iss_24810_1.rs:6:15: 6:16 error: the trait `T` cannot be made into an object [E0038]
iss_24810_1.rs:6 impl T<Output=T> {
                               ^
iss_24810_1.rs:6:15: 6:16 help: run `rustc --explain E0038` to see a detailed explanation
iss_24810_1.rs:6:15: 6:16 note: the trait cannot use `Self` as a type parameter in the supertrait listing
iss_24810_1.rs:6:6: 6:17 error: the trait `T` cannot be made into an object [E0038]
iss_24810_1.rs:6 impl T<Output=T> {
                      ^~~~~~~~~~~
iss_24810_1.rs:6:6: 6:17 help: run `rustc --explain E0038` to see a detailed explanation
iss_24810_1.rs:6:6: 6:17 note: the trait cannot use `Self` as a type parameter in the supertrait listing
error: aborting due to 2 previous errors

The second gives a similar error:

iss_24810_2.rs:6:12: 6:23 error: the trait `T` cannot be made into an object [E0038]
iss_24810_2.rs:6 impl<X: T> T<Output=X> {
                            ^~~~~~~~~~~
iss_24810_2.rs:6:12: 6:23 help: run `rustc --explain E0038` to see a detailed explanation
iss_24810_2.rs:6:12: 6:23 note: the trait cannot use `Self` as a type parameter in the supertrait listing
iss_24810_2.rs:6:6: 6:7 error: the type parameter `X` is not constrained by the impl trait, self type, or predicates [E0207]
iss_24810_2.rs:6 impl<X: T> T<Output=X> {
                      ^
iss_24810_2.rs:6:6: 6:7 help: run `rustc --explain E0207` to see a detailed explanation
error: aborting due to 2 previous errors

The third example also results in E0038.

Can this issue be closed?

@Mark-Simulacrum
Copy link
Member

Closing, as per the note in the previous comment.

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

5 participants