Skip to content

ICE: coherence failed to report ambiguity when sending a struct including PhantomData #25368

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
Munksgaard opened this issue May 13, 2015 · 2 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@Munksgaard
Copy link
Contributor

use std::sync::mpsc::channel;
use std::thread::spawn;
use std::marker::PhantomData;

struct Foo<T> {foo: PhantomData<T>}

fn main() {
    let (tx, rx) = channel();

    spawn(move || {
        tx.send(Foo{ foo: PhantomData });
    });
}

fails to compile with the following error (on playpen nightly 2014-05-13):

<anon>:10:5: 10:10 error: internal compiler error: coherence failed to report ambiguity: cannot locate the impl of the trait `core::marker::Send` for the type `[closure <anon>:10:16: 12:6]`
<anon>:10     spawn(move || {
              ^~~~~
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>', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libsyntax/diagnostic.rs:170

Here's the backtrace:

stack backtrace:
   1:     0x7fd0dba28b49 - sys::backtrace::write::h412fd048026f70e7uhs
   2:     0x7fd0dba30ac9 - panicking::on_panic::h29d81987ed54208bxXw
   3:     0x7fd0db9f0862 - rt::unwind::begin_unwind_inner::hb43cf3548917ef54HCw
   4:     0x7fd0d8dd3c4d - rt::unwind::begin_unwind::h5201448110574075268
   5:     0x7fd0d8dd3be2 - diagnostic::SpanHandler::span_bug::hb39065b9fe8fb3f2D2B
   6:     0x7fd0d9b43a49 - middle::traits::error_reporting::report_fulfillment_error::h2459ff2fb01b4302zTN
   7:     0x7fd0d99f4d41 - middle::traits::error_reporting::report_fulfillment_errors::hf108381206cc195cPSN
   8:     0x7fd0db198414 - check::vtable::select_all_fcx_obligations_or_error::ha187a7a966441c6df9b
   9:     0x7fd0db219262 - check::check_bare_fn::hde32c6ea2fd561e5FMn
  10:     0x7fd0db217142 - check::CheckItemBodiesVisitor<'a, 'tcx>.Visitor<'tcx>::visit_item::h1fe392053eb35855IJn
  11:     0x7fd0db2d1aca - check_crate::closure.38576
  12:     0x7fd0db2cb630 - check_crate::hdfe4c6ceaab6493fuCC
  13:     0x7fd0dbf890a8 - driver::phase_3_run_analysis_passes::h3c7402bc8b274a4ctGa
  14:     0x7fd0dbf69eac - driver::compile_input::h34062f722e30b378Qba
  15:     0x7fd0dc025e31 - run_compiler::h58bdb62ca09f7a7275b
  16:     0x7fd0dc023682 - boxed::F.FnBox<A>::call_box::h2254708566657730251
  17:     0x7fd0dc022c49 - rt::unwind::try::try_fn::h5284975654559288511
  18:     0x7fd0dbab3f98 - rust_try_inner
  19:     0x7fd0dbab3f85 - rust_try
  20:     0x7fd0dc022ee4 - boxed::F.FnBox<A>::call_box::h4931667208008540516
  21:     0x7fd0dba2f861 - sys::thread::Thread::new::thread_start::hb8b1207e6c09cbe43Iv
  22:     0x7fd0d64732c3 - <unknown>
  23:     0x7fd0db6872dc - clone
  24:                0x0 - <unknown>

This is probably related to #24424, but doesn't include any lifetimes.

@steveklabnik steveklabnik added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label May 13, 2015
@arielb1
Copy link
Contributor

arielb1 commented May 27, 2015

Self-contained:

struct Foo<T>(Option<T>);

fn spawn<T: Send>(_: T) {}

struct Tx<T: Send>(Option<T>);

impl<T: Send> Tx<T> {
    fn send(&self, _: T) {}
}

fn channel<T: Send>() -> Tx<T> { Tx(None) }

fn main() {
    let tx = channel();

    spawn(move || {
        tx.send(Foo(None));
    });
}

I think I got it.

@Munksgaard
Copy link
Contributor Author

👍 Good job!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

3 participants