Skip to content

ICE in trait impl with where clause #20413

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
Twisol opened this issue Jan 2, 2015 · 5 comments
Closed

ICE in trait impl with where clause #20413

Twisol opened this issue Jan 2, 2015 · 5 comments
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@Twisol
Copy link

Twisol commented Jan 2, 2015

rustc 0.13.0-nightly (7608dbad6 2014-12-31 10:06:21 -0800)
binary: rustc
commit-hash: 7608dbad651f02e837ed05eef3d74a6662a6e928
commit-date: 2014-12-31 10:06:21 -0800
host: x86_64-apple-darwin
release: 0.13.0-nightly
trait Foo<'a> {
  fn answer(&'a mut self) -> u8;
}

struct Newtype<'a, T: 'a> {
  value: &'a mut T,
}


impl<'a, T> Foo<'a> for T
where Newtype<'a, T>: Foo<'a> {
  fn answer(&'a mut self) -> u8 {
    let newtype: Newtype<'a, T> = Newtype{value: self};
    newtype.answer()
  }
}


fn main() {}
foo.rs:13:9: 13:16 error: internal compiler error: coherence failed to report ambiguity: cannot locate the impl of the trait `core::kinds::Sized` for the type `Newtype<'a, T>`
foo.rs:13     let newtype: Newtype<'a, T> = Newtype{value: self};
                  ^~~~~~~
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/rustbuild/src/rust-buildbot/slave/nightly-mac/build/src/libsyntax/diagnostic.rs:123

stack backtrace:
   1:        0x10a0121e5 - sys::backtrace::write::h4cebc8c3e368e8f0Upt
   2:        0x10a036c33 - failure::on_fail::hd9de93a6058d1a7dwwz
   3:        0x109f9ce6a - rt::unwind::begin_unwind_inner::h00d5ebf844629bb50dz
   4:        0x107ec9127 - rt::unwind::begin_unwind::h16325012161302436941
   5:        0x107ec90bc - diagnostic::SpanHandler::span_bug::h1cb2c7c5c82d285daPF
   6:        0x1076abc1e - middle::traits::error_reporting::report_fulfillment_error::h2148a74f54ee08d9QWO
   7:        0x1075886f2 - middle::traits::error_reporting::report_fulfillment_errors::h810f7f45fe3b1cb2lWO
   8:        0x106eb5062 - check::vtable::select_all_fcx_obligations_or_error::h571e4dea5c1362649mb
   9:        0x106f7373a - check::check_bare_fn::h1812c230f63b7673Qzj
  10:        0x106f78959 - check::check_method_body::h2ef2abe5be0f9daew2j
  11:        0x106f6d9fa - check::check_item::hac3080059fe09f34SSj
  12:        0x1070fee40 - check_crate::unboxed_closure.39832
  13:        0x1070fa733 - check_crate::h127b3439cfd8ff83NLx
  14:        0x106916d52 - driver::phase_3_run_analysis_passes::hadc5fda84afbf325qva
  15:        0x106903b88 - driver::compile_input::h9d2d7dddc58375d9wba
  16:        0x106a35843 - thunk::F.Invoke<A, R>::invoke::h1922614042677645733
  17:        0x106a329a0 - rt::unwind::try::try_fn::h5185751407680132505
  18:        0x10a09e5e9 - rust_try_inner
  19:        0x10a09e5d6 - rust_try
  20:        0x106a330e6 - thunk::F.Invoke<A, R>::invoke::h18183949975069308340
  21:        0x10a023544 - sys::thread::thread_start::h0fb21aaa7cc37e0dDfw
  22:     0x7fff8f8de2fc - _pthread_body
  23:     0x7fff8f8de279 - _pthread_body
@Twisol
Copy link
Author

Twisol commented Jan 2, 2015

Per theme in #rust, here's a minimized example exhibiting the same ICE:

trait Foo {
  fn answer(self);
}

struct NoData<T>;

impl<T> Foo for T
where NoData<T>: Foo {
  fn answer(self) {
    let val: NoData<T> = NoData;
  }
}


fn main() {}
foo.rs:10:9: 10:12 error: internal compiler error: coherence failed to report ambiguity: cannot locate the impl of the trait `core::kinds::Sized` for the type `NoData<T>`
foo.rs:10     let val: NoData<T> = NoData;
                  ^~~
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/rustbuild/src/rust-buildbot/slave/nightly-mac/build/src/libsyntax/diagnostic.rs:123

stack backtrace:
   1:        0x10d1fa1e5 - sys::backtrace::write::h4cebc8c3e368e8f0Upt
   2:        0x10d21ec33 - failure::on_fail::hd9de93a6058d1a7dwwz
   3:        0x10d184e6a - rt::unwind::begin_unwind_inner::h00d5ebf844629bb50dz
   4:        0x10b09a127 - rt::unwind::begin_unwind::h16325012161302436941
   5:        0x10b09a0bc - diagnostic::SpanHandler::span_bug::h1cb2c7c5c82d285daPF
   6:        0x10a880c1e - middle::traits::error_reporting::report_fulfillment_error::h2148a74f54ee08d9QWO
   7:        0x10a75d6f2 - middle::traits::error_reporting::report_fulfillment_errors::h810f7f45fe3b1cb2lWO
   8:        0x10a08f062 - check::vtable::select_all_fcx_obligations_or_error::h571e4dea5c1362649mb
   9:        0x10a14d73a - check::check_bare_fn::h1812c230f63b7673Qzj
  10:        0x10a152959 - check::check_method_body::h2ef2abe5be0f9daew2j
  11:        0x10a1479fa - check::check_item::hac3080059fe09f34SSj
  12:        0x10a2d8e40 - check_crate::unboxed_closure.39832
  13:        0x10a2d4733 - check_crate::h127b3439cfd8ff83NLx
  14:        0x109afcd52 - driver::phase_3_run_analysis_passes::hadc5fda84afbf325qva
  15:        0x109ae9b88 - driver::compile_input::h9d2d7dddc58375d9wba
  16:        0x109c1b843 - thunk::F.Invoke<A, R>::invoke::h1922614042677645733
  17:        0x109c189a0 - rt::unwind::try::try_fn::h5185751407680132505
  18:        0x10d2865e9 - rust_try_inner
  19:        0x10d2865d6 - rust_try
  20:        0x109c190e6 - thunk::F.Invoke<A, R>::invoke::h18183949975069308340
  21:        0x10d20b544 - sys::thread::thread_start::h0fb21aaa7cc37e0dDfw
  22:     0x7fff8f8de2fc - _pthread_body
  23:     0x7fff8f8de279 - _pthread_body

@theemathas
Copy link
Contributor

This also triggers an ICE.

trait Foo { }

struct NoData<T>;

impl<T> NoData<T> where NoData<T>: Foo {
    fn any_fn() {
        let val: NoData<T> = NoData;
    }
}

fn main() { }

The error and backtrace:

compiler_bug.rs:7:13: 7:16 error: internal compiler error: coherence failed to report ambiguity: cannot locate the impl of the trait `core::kinds::Sized` for the type `NoData<T>`
compiler_bug.rs:7         let val: NoData<T> = NoData;
                              ^~~
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-linux/build/src/libsyntax/diagnostic.rs:123

stack backtrace:
   1:     0x7f55f88b4950 - sys::backtrace::write::h895a7595e35ffe42gnt
   2:     0x7f55f88d9660 - failure::on_fail::hb3298435971cff34kEz
   3:     0x7f55f8840940 - rt::unwind::begin_unwind_inner::h6dee24d5dc335a63oiz
   4:     0x7f55f3a09cc0 - rt::unwind::begin_unwind::h12623432956124006653
   5:     0x7f55f3a09c50 - diagnostic::SpanHandler::span_bug::hb1e8fbfda78f91d3aPF
   6:     0x7f55f6c43f80 - middle::traits::error_reporting::report_fulfillment_error::hc3d51bb26b08511dQWO
   7:     0x7f55f6b1d0b0 - middle::traits::error_reporting::report_fulfillment_errors::h416175d5a65156fclWO
   8:     0x7f55f7e7bf50 - check::vtable::select_all_fcx_obligations_or_error::hab001ea061dfaa499mb
   9:     0x7f55f7f3f2c0 - check::check_bare_fn::h24d3cb693ab9ca75Qzj
  10:     0x7f55f7f44a70 - check::check_method_body::h18ea7cf32e2032f6w2j
  11:     0x7f55f7f36950 - check::check_item::hb991f99d47aa82ceSSj
  12:     0x7f55f80d7030 - check_crate::unboxed_closure.39833
  13:     0x7f55f80d1dd0 - check_crate::hb802e7bb2dee1cd6NLx
  14:     0x7f55f8dfd860 - driver::phase_3_run_analysis_passes::h83e2236a47a83223qva
  15:     0x7f55f8dec0a0 - driver::compile_input::h2bdea93b5d9f3dbfwba
  16:     0x7f55f8f37970 - thunk::F.Invoke<A, R>::invoke::h11261394929911795771
  17:     0x7f55f8f36720 - rt::unwind::try::try_fn::h18390836921836612068
  18:     0x7f55f893f2d0 - rust_try_inner
  19:     0x7f55f893f2c0 - rust_try
  20:     0x7f55f8f36a70 - thunk::F.Invoke<A, R>::invoke::h16439250889300796363
  21:     0x7f55f88c6300 - sys::thread::thread_start::haeaaf0233fbdd5c3bgw
  22:     0x7f55f322a0c0 - start_thread
  23:     0x7f55f84e6ec9 - __clone
  24:                0x0 - <unknown>

output of rustc --version --verbose

rustc 0.13.0-nightly (7608dbad6 2014-12-31 10:06:21 -0800)
binary: rustc
commit-hash: 7608dbad651f02e837ed05eef3d74a6662a6e928
commit-date: 2014-12-31 10:06:21 -0800
host: x86_64-unknown-linux-gnu
release: 0.13.0-nightly

Note that removing the where clause eliminates the error. (although it isn't used anywhere)

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

Yet another variant:

trait Foo { }

struct NoData<T>;

fn any_fn<T>() where NoData<T>: Foo {
    let val: NoData<T> = NoData;
}

fn main() { }
compiler_bug.rs:6:9: 6:12 error: internal compiler error: coherence failed to report ambiguity: cannot locate the impl of the trait `core::kinds::Sized` for the type `NoData<T>`
compiler_bug.rs:6     let val: NoData<T> = NoData;
                          ^~~
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-linux/build/src/libsyntax/diagnostic.rs:123

stack backtrace:
   1:     0x7f9a9b66f950 - sys::backtrace::write::h895a7595e35ffe42gnt
   2:     0x7f9a9b694660 - failure::on_fail::hb3298435971cff34kEz
   3:     0x7f9a9b5fb940 - rt::unwind::begin_unwind_inner::h6dee24d5dc335a63oiz
   4:     0x7f9a967c4cc0 - rt::unwind::begin_unwind::h12623432956124006653
   5:     0x7f9a967c4c50 - diagnostic::SpanHandler::span_bug::hb1e8fbfda78f91d3aPF
   6:     0x7f9a999fef80 - middle::traits::error_reporting::report_fulfillment_error::hc3d51bb26b08511dQWO
   7:     0x7f9a998d80b0 - middle::traits::error_reporting::report_fulfillment_errors::h416175d5a65156fclWO
   8:     0x7f9a9ac36f50 - check::vtable::select_all_fcx_obligations_or_error::hab001ea061dfaa499mb
   9:     0x7f9a9acfa2c0 - check::check_bare_fn::h24d3cb693ab9ca75Qzj
  10:     0x7f9a9acf1950 - check::check_item::hb991f99d47aa82ceSSj
  11:     0x7f9a9ae92030 - check_crate::unboxed_closure.39833
  12:     0x7f9a9ae8cdd0 - check_crate::hb802e7bb2dee1cd6NLx
  13:     0x7f9a9bbb8860 - driver::phase_3_run_analysis_passes::h83e2236a47a83223qva
  14:     0x7f9a9bba70a0 - driver::compile_input::h2bdea93b5d9f3dbfwba
  15:     0x7f9a9bcf2970 - thunk::F.Invoke<A, R>::invoke::h11261394929911795771
  16:     0x7f9a9bcf1720 - rt::unwind::try::try_fn::h18390836921836612068
  17:     0x7f9a9b6fa2d0 - rust_try_inner
  18:     0x7f9a9b6fa2c0 - rust_try
  19:     0x7f9a9bcf1a70 - thunk::F.Invoke<A, R>::invoke::h16439250889300796363
  20:     0x7f9a9b681300 - sys::thread::thread_start::haeaaf0233fbdd5c3bgw
  21:     0x7f9a95fe50c0 - start_thread
  22:     0x7f9a9b2a1ec9 - __clone
  23:                0x0 - <unknown>

@theemathas
Copy link
Contributor

Slight variant:

trait Foo { }

struct NoData<T>;

fn any_fn<T>() where NoData<T>: Foo {
    let val = NoData::<T>;
}

fn main() { }
compiler_bug2.rs:6:9: 6:12 error: internal compiler error: coherence failed to report ambiguity: cannot locate the impl of the trait `core::kinds::Sized` for the type `NoData<T>`
compiler_bug2.rs:6     let val = NoData::<T>;
                           ^~~
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-linux/build/src/libsyntax/diagnostic.rs:123

stack backtrace:
   1:     0x7f467f67e950 - sys::backtrace::write::h895a7595e35ffe42gnt
   2:     0x7f467f6a3660 - failure::on_fail::hb3298435971cff34kEz
   3:     0x7f467f60a940 - rt::unwind::begin_unwind_inner::h6dee24d5dc335a63oiz
   4:     0x7f467a7d3cc0 - rt::unwind::begin_unwind::h12623432956124006653
   5:     0x7f467a7d3c50 - diagnostic::SpanHandler::span_bug::hb1e8fbfda78f91d3aPF
   6:     0x7f467da0df80 - middle::traits::error_reporting::report_fulfillment_error::hc3d51bb26b08511dQWO
   7:     0x7f467d8e70b0 - middle::traits::error_reporting::report_fulfillment_errors::h416175d5a65156fclWO
   8:     0x7f467ec45f50 - check::vtable::select_all_fcx_obligations_or_error::hab001ea061dfaa499mb
   9:     0x7f467ed092c0 - check::check_bare_fn::h24d3cb693ab9ca75Qzj
  10:     0x7f467ed00950 - check::check_item::hb991f99d47aa82ceSSj
  11:     0x7f467eea1030 - check_crate::unboxed_closure.39833
  12:     0x7f467ee9bdd0 - check_crate::hb802e7bb2dee1cd6NLx
  13:     0x7f467fbc7860 - driver::phase_3_run_analysis_passes::h83e2236a47a83223qva
  14:     0x7f467fbb60a0 - driver::compile_input::h2bdea93b5d9f3dbfwba
  15:     0x7f467fd01970 - thunk::F.Invoke<A, R>::invoke::h11261394929911795771
  16:     0x7f467fd00720 - rt::unwind::try::try_fn::h18390836921836612068
  17:     0x7f467f7092d0 - rust_try_inner
  18:     0x7f467f7092c0 - rust_try
  19:     0x7f467fd00a70 - thunk::F.Invoke<A, R>::invoke::h16439250889300796363
  20:     0x7f467f690300 - sys::thread::thread_start::haeaaf0233fbdd5c3bgw
  21:     0x7f4679ff40c0 - start_thread
  22:     0x7f467f2b0ec9 - __clone
  23:                0x0 - <unknown>

@milibopp
Copy link
Contributor

milibopp commented Feb 3, 2015

I'm currently getting the following ICE on the latest version of nalgebra:

src/lib.rs:612:7: 612:19 error: internal compiler error: coherence failed to report ambiguity: cannot locate the impl of the trait `traits::structure::Mat<N, LV, LV>` for the type `<R as traits::geometry::RotationMatrix<N, LV, AV>>::Output`
src/lib.rs:612     r.to_rot_mat()
                     ^~~~~~~~~~~~
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:129

stack backtrace:
   1:     0x7f8f70bb3e80 - sys::backtrace::write::h84a1347ec8a3d425Aru
   2:     0x7f8f70bd74a0 - failure::on_fail::h1cb2299eb5e255ae9GB
   3:     0x7f8f70b422d0 - rt::unwind::begin_unwind_inner::ha34a1c7f0630f466IlB
   4:     0x7f8f6df5dbf0 - rt::unwind::begin_unwind::h12804436560652988965
   5:     0x7f8f6df5db80 - diagnostic::SpanHandler::span_bug::h7782d96edbc369daAME
   6:     0x7f8f6eca4890 - middle::traits::error_reporting::report_fulfillment_errors::h9d98ce1dd7e3fcdeGnN
   7:     0x7f8f702a1a20 - check::vtable::select_all_fcx_obligations_or_error::hc5e5e8e652f479efRvb
   8:     0x7f8f70351680 - check::check_bare_fn::h306f8ecc226858bctAm
   9:     0x7f8f70348e70 - check::check_item::h7d555ba822408851KTm
  10:     0x7f8f70417d10 - check_crate::closure.34569
  11:     0x7f8f70412850 - check_crate::h2469153404b647bauEA
  12:     0x7f8f71144710 - driver::phase_3_run_analysis_passes::h198ed79d6101094dtGa
  13:     0x7f8f7112b2b0 - driver::compile_input::h08caf95be513bd6bBba
  14:     0x7f8f711f5dd0 - run_compiler::hf1a36c26381910e09ac
  15:     0x7f8f711f4460 - thunk::F.Invoke<A, R>::invoke::h6996223324138754953
  16:     0x7f8f711f3390 - rt::unwind::try::try_fn::h16059966258548481805
  17:     0x7f8f70c42910 - rust_try_inner
  18:     0x7f8f70c42900 - rust_try
  19:     0x7f8f711f3640 - thunk::F.Invoke<A, R>::invoke::h12998514134271589737
  20:     0x7f8f70bc3ca0 - sys::thread::thread_start::h756cedb2df1b4200Pnx
  21:     0x7f8f6ade3250 - start_thread
  22:     0x7f8f707d4219 - clone
  23:                0x0 - <unknown>

The relevant code fragments:

/// Trait of transformation having a rotation extractable as a rotation matrix. This can typically
/// be implemented by quaternions to convert them to a rotation matrix.
pub trait RotationMatrix<N, LV, AV> : Rotation<AV> {
    type Output: Mat<N, LV, LV> + Rotation<AV>;

    /// Gets the rotation matrix represented by `self`.
    fn to_rot_mat(&self) -> Self::Output;
}
/// Builds a rotation matrix from `r`.
#[inline(always)]
pub fn to_rot_mat<N, LV, AV, R: RotationMatrix<N, LV, AV>>(r: &R) -> R::Output {
    r.to_rot_mat()
}

Changing the method call to use function notation, i.e. RotationMatrix::to_rot_mat(r), as indicated in #20414 did not work here.

milibopp added a commit to milibopp/nalgebra that referenced this issue Feb 3, 2015
The associated type bound here was not parsed correctly. This is likely due to
the ICE described in rust-lang/rust#20413.
@ghost ghost added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Apr 3, 2015
jooert added a commit to jooert/rust that referenced this issue May 12, 2015
@bors bors closed this as completed in 23300a3 May 13, 2015
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

4 participants