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

"coherence failed to report ambiguity" ICE Involving Lifetimes #24424

Closed
kyledewey opened this issue Apr 14, 2015 · 9 comments
Closed

"coherence failed to report ambiguity" ICE Involving Lifetimes #24424

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

Comments

@kyledewey
Copy link

The following causes an ICE:

trait Trait1<'l0, T0> {}
trait Trait0<'l0>  {}

impl <'l0, 'l1, T0> Trait1<'l0, T0> for bool where T0 : Trait0<'l0>, T0 : Trait0<'l1> {}

fn main() {}

Backtrace:

crash.rs:4:1: 4:89 error: internal compiler error: coherence failed to report ambiguity: cannot locate the impl of the trait `Trait0<'_>` for the type `T0`
crash.rs:4 impl <'l0, 'l1, T0> Trait1<'l0, T0> for bool where T0 : Trait0<'l0>, T0 : Trait0<'l1> {}

stack backtrace:
   1:        0x10e27099f - sys::backtrace::write::h65efba87d2ac2b9cGGC
   2:        0x10e297ae2 - panicking::on_panic::h7344421187b575a3mGI
   3:        0x10e1ce9f5 - rt::unwind::begin_unwind_inner::h0fb3967931f800c95nI
   4:        0x10d9ac11e - rt::unwind::begin_unwind::h14950887375606487128
   5:        0x10d9ac0aa - diagnostic::SpanHandler::span_bug::hce9df0bd0b4a6d6bsmB
   6:        0x10b3ae93e - middle::traits::error_reporting::report_fulfillment_errors::h914196447e3f8e39tRN
   7:        0x10aa7f283 - check::vtable::select_all_fcx_obligations_or_error::heb0bf2b308159b20P1b
   8:        0x10aaf585d - check::wf::CheckTypeWellFormedVisitor<'ccx, 'tcx>::check_item_well_formed::h8592f75fbcdfabe4kWk
   9:        0x10abe603e - check_crate::closure.38354
  10:        0x10abe1517 - check_crate::hc0c9219806b9606cnuC
  11:        0x10a934a62 - driver::phase_3_run_analysis_passes::h22c1ac11f5719067nGa
  12:        0x10a91677c - driver::compile_input::ha52ae5794027c2d3Qba
  13:        0x10a9dc873 - run_compiler::h88dac0540af48212F4b
  14:        0x10a9da39a - boxed::F.FnBox<A>::call_box::h782914981501029945
  15:        0x10a9d9837 - rt::unwind::try::try_fn::h11237440895302402829
  16:        0x10e31fa48 - rust_try_inner
  17:        0x10e31fa35 - rust_try
  18:        0x10a9d9b10 - boxed::F.FnBox<A>::call_box::h3896333940280334120
  19:        0x10e283e9d - sys::thread::create::thread_start::hb17c0976197a6554xnH
  20:     0x7fff8df11741 - _pthread_start

With:

% rustc --version
rustc 1.0.0-nightly (e6a812402 2015-04-14) (built 2015-04-13)

I can confirm that this bug has been around since 1.0.0-alpha (though with a slightly different assertion violation; I accidentally posted that version originally).

@kyledewey
Copy link
Author

Removing either constraint in the where clause, or changing the lifetimes used in the where clause to be the same causes the ICE to go away.

@arielb1
Copy link
Contributor

arielb1 commented Apr 15, 2015

I guess we should change that error message to be different from "coherence failed to report ambiguity" to "trait selection failed".

Your use-case isn't currently supported (#21974). Not sure which error message to give, through.

@steveklabnik steveklabnik added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Apr 16, 2015
@frewsxcv
Copy link
Member

A couple more examples of this (including a nightly regression) can be found in #27989

@malbarbo
Copy link
Contributor

With rustc 1.7.0, 1.8.0 and 1.9.0, the example fails to compile, but don't generate an ICE.

@frewsxcv
Copy link
Member

Added a regression test in #34453.

frewsxcv added a commit to frewsxcv/rust that referenced this issue Jun 25, 2016
bors added a commit that referenced this issue Jun 27, 2016
@kyledewey
Copy link
Author

It's been awhile since I reported this and I'm woefully out of the loop on Rust development at this point, but I'm not fully understanding the fix. The current error message is that additional type annotations are required, but my understanding of the original problem is that this is a fundamental limitation of the typechecker. Is there a way to add in more type annotations here to make this compile? I tried playing around with this a bit, but I wasn't able to come up with anything concrete.

@nikomatsakis
Copy link
Contributor

@kyledewey you're not wrong, the error message is poor.

@nikomatsakis
Copy link
Contributor

it's a limitation of the existing solver, anyway. (also, sorry for the like 2+ year gap here :) just happened to be looking at this issue)

@kyledewey
Copy link
Author

@nikomatsakis thanks for the clarification, hello, and no problem! :)

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

6 participants