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

ICE: Conflicting trait impls with custom default-implemented trait bound #29516

Closed
rphmeier opened this issue Nov 2, 2015 · 4 comments
Closed
Labels
C-bug Category: This is a bug. E-needs-test Call for participation: Writing correctness tests. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@rphmeier
Copy link
Contributor

rphmeier commented Nov 2, 2015

This stems from my attempt to extend the NotSame trait for type inequality as described in #29499 to tuples of arbitrary size. The implementation for (A, B) conflicts with the implementation for A because the (A) tuple lacks a trailing comma.

#![feature(optin_builtin_traits)]

trait NotSame {}
impl NotSame for .. {}
impl<A> !NotSame for (A, A) {}

trait OneOfEach {}

impl <A> OneOfEach for (A) { }

impl <A, B> OneOfEach for (A, B) where (B): OneOfEach, (A, B): NotSame { }

// ...

fn main() {}
robert@laptop:~/projects/one_of_each$ RUST_BACKTRACE=1 rustc one_of_each.rs
one_of_each.rs:11:1: 11:75 error: internal compiler error: coherence failed to report ambiguity: cannot locate the impl of the trait `OneOfEach` for the type `(A, B)`
one_of_each.rs:11 impl <A, B> OneOfEach for (A, B) where (B): OneOfEach, (A, B): NotSame { }
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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
thread 'rustc' panicked at 'Box<Any>', ../src/libsyntax/diagnostic.rs:176
stack backtrace:
   1:     0x7f8e6d26fd20 - sys::backtrace::tracing::imp::write::h5839347184a363c1Tnt
   2:     0x7f8e6d2765e5 - panicking::log_panic::_<closure>::closure.39955
   3:     0x7f8e6d276055 - panicking::log_panic::hcde6d42710304abbWnx
   4:     0x7f8e6d239683 - sys_common::unwind::begin_unwind_inner::h4039843fef6bffefYgs
   5:     0x7f8e670c63c7 - sys_common::unwind::begin_unwind::begin_unwind::h17811388397816602357
   6:     0x7f8e670c6386 - diagnostic::_<impl>::span_bug::h517cd016f9a1ed4fqGA
   7:     0x7f8e6b04f4a0 - middle::traits::error_reporting::report_fulfillment_errors::h7b40fdbf7b69efa1DqR
   8:     0x7f8e6bdf69b5 - check::_<impl>::select_all_obligations_or_error::h68d2b62f895fda24Nar
   9:     0x7f8e6be4d9a4 - check::wf::_<impl>::check_item_well_formed::h294fa0c9be11cb26O4j
  10:     0x7f8e6be8bfbe - check::check_wf_old::h2896130387effa64m9o
  11:     0x7f8e6bf3b8ab - check_crate::hbd4bd8f4f3340ed1BrD
  12:     0x7f8e6d7438b9 - driver::phase_3_run_analysis_passes::_<closure>::closure.21990
  13:     0x7f8e6d729213 - middle::ty::context::_<impl>::create_and_enter::create_and_enter::h7648551165536465273
  14:     0x7f8e6d72420e - driver::phase_3_run_analysis_passes::h13807885485637783892
  15:     0x7f8e6d704c92 - driver::compile_input::he5c7814d86abe8678ba
  16:     0x7f8e6d85badb - run_compiler::h3e946a4e9bc089bfvqc
  17:     0x7f8e6d858b56 - sys_common::unwind::try::try_fn::try_fn::h18225326314371046170
  18:     0x7f8e6d26da48 - __rust_try
  19:     0x7f8e6d261abb - sys_common::unwind::try::inner_try::h81e998e565f2181dwds
  20:     0x7f8e6d858ea4 - boxed::_<impl>::call_box::call_box::h16507595822000360715
  21:     0x7f8e6d2750b3 - sys::thread::_<impl>::new::thread_start::h0be42f811434f5398Fw
  22:     0x7f8e6691c181 - start_thread
  23:     0x7f8e6ceef47c - __clone
  24:                0x0 - <unknown>

On rustc 1.6.0-nightly (1a2eaff 2015-10-31)

@bluss
Copy link
Member

bluss commented Nov 2, 2015

Note that you need to say (A, ) with comma to get an unary tuple (a singlet?)

@apasel422 apasel422 added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Nov 2, 2015
@rphmeier
Copy link
Contributor Author

rphmeier commented Nov 3, 2015

@bluss Thanks for clarifying, I mentioned this in the original issue but phrased it poorly. Note that this does compile with the trailing comma.

@pmarcelll
Copy link
Contributor

Triage: I cannot reproduce the ICE with the current code.

@Mark-Simulacrum
Copy link
Member

Given added commas, I cannot reproduce the ICE today. E-needstest.

#![feature(optin_builtin_traits)]

trait NotSame {}
impl NotSame for .. {}
impl<A> !NotSame for (A, A) {}

trait OneOfEach {}

impl<A> OneOfEach for (A,) { }

impl<A, B> OneOfEach for (A, B)
    where (B,): OneOfEach,
          (A, B): NotSame { }

// ...

fn main() {}

@Mark-Simulacrum Mark-Simulacrum added the E-needs-test Call for participation: Writing correctness tests. label Jun 12, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-bug Category: This is a bug. label Jul 22, 2017
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue Jul 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. E-needs-test Call for participation: Writing correctness tests. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

5 participants