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 #23336

Closed
frankmcsherry opened this issue Mar 13, 2015 · 7 comments
Closed

"coherence failed to report ambiguity" ICE #23336

frankmcsherry opened this issue Mar 13, 2015 · 7 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@frankmcsherry
Copy link
Contributor

The following ICEs for me (full ICE text below):

use communication::channels::Data;

pub trait UnaryLogic {
    type D: Data;
}

pub struct Test<D: Data> {
    data: D,
}

pub struct UnaryScope<L: UnaryLogic> {
    input: Test<L::D>,
}

I get the following backtrace:

% cargo build
   Compiling timely v0.0.4 (file:///Users/mcsherry/Projects/timely-dataflow)
src/example/unary.rs:11:1: 13:2 error: internal compiler error: coherence failed to report ambiguity: cannot locate the impl of the trait `communication::channels::Data` for the type `<L as example::unary::UnaryLogic>::D`
src/example/unary.rs:11 pub struct UnaryScope<L: UnaryLogic> {
src/example/unary.rs:12     input:          Test<L::D>,
src/example/unary.rs:13 }
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 'Box<Any>', /Users/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-mac/build/src/libsyntax/diagnostic.rs:129

stack backtrace:
   1:        0x1049b9892 - sys::backtrace::write::h7ca860691254c21a9EC
   2:        0x1049e2a94 - panicking::on_panic::h732e2bcc29cede42AyI
   3:        0x104900ad7 - rt::unwind::begin_unwind_inner::h1d9a458f1c8a477f9gI
   4:        0x1040c2d4e - rt::unwind::begin_unwind::h1806603646409102692
   5:        0x1040c2cfb - diagnostic::SpanHandler::span_bug::h5e5d13971cb26e4dEaB
   6:        0x101a77431 - middle::traits::error_reporting::report_fulfillment_errors::hec79282105dfc6c0WkM
   7:        0x10101fc26 - check::vtable::select_all_fcx_obligations_or_error::h4a9679ed212bc030AWb
   8:        0x1010a003b - check::wf::CheckTypeWellFormedVisitor<'ccx, 'tcx>::check_item_well_formed::h84e6bab21402d285QGk
   9:        0x1010aa051 - visit::walk_item::h9436359046113201614
  10:        0x1010aa05c - visit::walk_item::h9436359046113201614
  11:        0x1011a0cb8 - check_crate::closure.35769
  12:        0x10119b9a0 - check_crate::ha4e5273863a0bceeO3B
  13:        0x100ebfd77 - driver::phase_3_run_analysis_passes::h01b4fa77db9aaa7cmGa
  14:        0x100ea7a42 - driver::compile_input::h5df8247b96c8ac29Nba
  15:        0x100f6bc0e - run_compiler::hc5bb62c076e88e08u2b
  16:        0x100f69197 - thunk::F.Invoke<A, R>::invoke::h9769882432828023548
  17:        0x100f67cff - rt::unwind::try::try_fn::h14950367479488448221
  18:        0x104a60ee8 - rust_try_inner
  19:        0x104a60ed5 - rust_try
  20:        0x100f68517 - thunk::F.Invoke<A, R>::invoke::h9709853396428516555
  21:        0x1049cfb22 - sys::thread::thread_start::hf2283362513a44b5o0G
  22:     0x7fff8b4ad2fb - _pthread_body
  23:     0x7fff8b4ad278 - _pthread_start

Could not compile `timely`.

To learn more, run the command again with --verbose.

with

% cargo --version
cargo 0.0.1-pre-nightly (66849de 2015-03-10) (built 2015-03-11)

The Data trait is just some mash-up of other traits, off in another file. Not clear if this is a "you wrote bad code, but the compiler barfed telling you" or "nope; that should work". Seems like ICE probably not the right answer in either case, though! :D

@arielb1
Copy link
Contributor

arielb1 commented Mar 13, 2015

It's a bug - we forgot to normalize the type.

@arielb1
Copy link
Contributor

arielb1 commented Mar 13, 2015

Actually, this is a typeck coherence error (I thought these were all trans errors). Could you try to give an example that causes the ICE?

cc @nikomatsakis

@frankmcsherry
Copy link
Contributor Author

The simplest possible repro I could think of (an empty Data trait in another file, plus the above) doesn't seem to cause the ICE. Let me try ripping up the project it is exploding in until I get something with less code (unless the reason for the ICE occurs to you; then I'll stop :)).

@frankmcsherry
Copy link
Contributor Author

Putting the following in playpen causes the ICE for me at the moment. Looking at it in this distilled form, it does seem a bit suspicious (like, maybe it shouldn't work ;)). But, still ICEs, and probably shouldn't do that at least.

trait Data : Clone+Send+'static { }
impl<T: Clone+Send+'static> Data for T { }

pub trait UnaryLogic {
    type D: Data;
}

pub struct Test<D: Data> {
    data: D,
}

pub struct UnaryScope<L: UnaryLogic> {
    input: Test<L::D>,
}

fn main() {}

@arielb1
Copy link
Contributor

arielb1 commented Mar 15, 2015

We error on a trivial ambiguity between a blanket ImplCandidate and a ProjectionCandidate. Definitely a bug in rustc.

@arielb1
Copy link
Contributor

arielb1 commented Mar 15, 2015

Less obscure:

pub trait Data { fn doit(&self) {} }
impl<T> Data for T { }
pub trait UnaryLogic { type D: Data; }

pub fn ice<T: UnaryLogic>(t: T::D) {
    t.doit();
}

fn main() {}

@nikomatsakis
Copy link
Contributor

cc me, I agree with @arielb1's diagnosis

@steveklabnik steveklabnik added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Mar 19, 2015
@bors bors closed this as completed in 2a12e51 May 12, 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