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

Compiler crash with new default parameters #20532

Closed
flying-sheep opened this issue Jan 4, 2015 · 3 comments
Closed

Compiler crash with new default parameters #20532

flying-sheep opened this issue Jan 4, 2015 · 3 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@flying-sheep
Copy link

When trying to use this feature in japaric-archived/complex.rs#9, the following happened:

   Compiling complex v0.0.0 (file:///home/phil/Dev/rust/_foreign_projects/complex.rs)
/home/phil/Dev/rust/_foreign_projects/complex.rs/src/lib.rs:149:1: 156:2 error: internal compiler error: impl `VtableImpl(impl_def_id=DefId { krate: 0, node: 1681 }:Complex<T>.Neg, substs=Substs[types=[[_];[];[]], regions=[[];[];[]]], nested=[[Obligation(predicate=Binder(TraitPredicate(TraitRef(T, core::kinds::Sized))),depth=1), Obligation(predicate=Binder(TraitPredicate(TraitRef(T, core::ops::Neg))),depth=1)];[];[]])` did not contain projection for `Obligation(predicate=<Complex<T> as TraitRef(Complex<T>, core::ops::Neg)>::Output,depth=0)`
/home/phil/Dev/rust/_foreign_projects/complex.rs/src/lib.rs:149 impl<T> Neg for Complex<T> where T: Neg {
/home/phil/Dev/rust/_foreign_projects/complex.rs/src/lib.rs:150     fn neg(self) -> Complex<T> {
/home/phil/Dev/rust/_foreign_projects/complex.rs/src/lib.rs:151         Complex {
/home/phil/Dev/rust/_foreign_projects/complex.rs/src/lib.rs:152             re: -self.re,
/home/phil/Dev/rust/_foreign_projects/complex.rs/src/lib.rs:153             im: -self.im,
/home/phil/Dev/rust/_foreign_projects/complex.rs/src/lib.rs:154         }
                                                                ...
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>', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libsyntax/diagnostic.rs:123

stack backtrace:
   1:     0x7f6d403552d0 - sys::backtrace::write::h8532e701ef86014f4it
   2:     0x7f6d4037ab00 - failure::on_fail::h7532e1f79d134d5dzvz
   3:     0x7f6d402e01c0 - rt::unwind::begin_unwind_inner::h97b151606151d62deaz
   4:     0x7f6d3b1b4c60 - rt::unwind::begin_unwind::h15809447133099964284
   5:     0x7f6d3b1b4bf0 - diagnostic::SpanHandler::span_bug::he8142ababcc30c39DFF
   6:     0x7f6d3e6b3e70 - middle::traits::project::project_type::h947eece142ef049d52P
   7:     0x7f6d3e6b0fd0 - middle::traits::project::opt_normalize_projection_type::hb3defb9cc9365d1e8UP
   8:     0x7f6d3e69eba0 - middle::traits::project::normalize_projection_type::hdc293893275ee559JTP
   9:     0x7f6d3e6b2470 - middle::traits::project::AssociatedTypeNormalizer<'a, 'b, 'tcx>.TypeFolder<'tcx>::fold_ty::h801cbd2cdff2eff1kSP
  10:     0x7f6d3f96f2e0 - middle::ty_fold::Rc<T>.TypeFoldable<'tcx>::fold_with::h6325524173844043840
  11:     0x7f6d3f96fe90 - middle::ty_fold::VecPerParamSpace<T>.TypeFoldable<'tcx>::fold_with::h13884369302522804796
  12:     0x7f6d3f98b280 - check::FnCtxt<'a, 'tcx>::instantiate_bounds::hed550a9659b70335Oll
  13:     0x7f6d3f9a3fc0 - check::wf::CheckTypeWellFormedVisitor<'ccx, 'tcx>::check_impl::closure.29997
  14:     0x7f6d3f9a0430 - check::wf::CheckTypeWellFormedVisitor<'ccx, 'tcx>::with_fcx::hb1283961ed8977b7Gfi
  15:     0x7f6d3f9a6d70 - check::wf::CheckTypeWellFormedVisitor<'ccx, 'tcx>.Visitor<'v>::visit_item::h001ababd87597e37soi
  16:     0x7f6d3fb93fe0 - check_crate::unboxed_closure.40162
  17:     0x7f6d3fb8ec30 - check_crate::h19fb6dea5733566ajsx
  18:     0x7f6d408a6640 - driver::phase_3_run_analysis_passes::h46b1604d9f9f5633Tva
  19:     0x7f6d40894ae0 - driver::compile_input::h68b8602933aad8d7wba
  20:     0x7f6d4095feb0 - thunk::F.Invoke<A, R>::invoke::h18029802347644288836
  21:     0x7f6d4095ec60 - rt::unwind::try::try_fn::h6518866316425934196
  22:     0x7f6d403e1400 - rust_try_inner
  23:     0x7f6d403e13f0 - rust_try
  24:     0x7f6d4095efb0 - thunk::F.Invoke<A, R>::invoke::h15513809553472565307
  25:     0x7f6d40366e40 - sys::thread::thread_start::h5ea7ba97235331d5a9v
  26:     0x7f6d3a9d9250 - start_thread
  27:     0x7f6d3ff97219 - clone
  28:                0x0 - <unknown>

Could not compile `complex`.

To learn more, run the command again with --verbose.
@japaric
Copy link
Member

japaric commented Jan 4, 2015

Minimal script:

#![crate_type = "lib"]

use std::ops::Neg;

struct Complex<T>;

impl<T> Neg for Complex<T> where T: Neg {
    fn neg(self) -> Complex<T> {
        loop {}
    }
}

Tested with: rustc 0.13.0-nightly (c6c786671 2015-01-04 00:50:59 +0000)

cc @nikomatsakis (I don't know if you have already fixed this.)


@flying-sheep You are missing the associated type in the impl Neg and also you need to bound the assoc type in where T: Neg.

This should work:

#![crate_type = "lib"]
#![feature(associated_types)]

use std::ops::Neg;

struct Complex<T>;

impl<T> Neg for Complex<T> where T: Neg<Output=T> {
    type Output = Complex<T>;

    fn neg(self) -> Complex<T> {
        loop {}
    }
}

@flying-sheep
Copy link
Author

great, thanks! i just figured out the first part myself, but good thing i found this compiler bug!

and you mean that i need where T: Neg<Output=T>, as there already is where T: Neg…?

@kmcallister kmcallister added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Jan 4, 2015
@huonw
Copy link
Member

huonw commented Jan 5, 2015

Closing as a dupe of #20347, thanks for filing.

@huonw huonw closed this as completed Jan 5, 2015
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