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: DefID [...] was matchable against Obligation [...] but now is not #18623

Closed
tyler569 opened this issue Nov 4, 2014 · 5 comments · Fixed by #25344
Closed

ICE: DefID [...] was matchable against Obligation [...] but now is not #18623

tyler569 opened this issue Nov 4, 2014 · 5 comments · Fixed by #25344
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@tyler569
Copy link

tyler569 commented Nov 4, 2014

I don't really know what could be causing this bug, but this code

struct Test;

impl Add<i32, i32> for Test {
    fn add(&self, othr: &i32) -> i32 {
        othr + 1
    }
}

impl Add<f64, f64> for Test {
    fn add(&self, othr: &f64) -> f64 {
        othr + 2.0
    }
}

fn main() {
    let f = Test;
    println!("f + 3:   {}", f + 3);
    println!("f + 3.0: {}", f + 3.0);
}

using this version of rustc,

rustc 0.13.0-nightly (0a5e7f359 2014-11-03 23:16:55 +0000)
binary: rustc
commit-hash: 0a5e7f35949d18f312dca90af73e56aced6f2b0e
commit-date: 2014-11-03 23:16:55 +0000
host: x86_64-apple-darwin
release: 0.13.0-nightly

on Mac OS X 10.10
causes

[tyler@mac ~]$ RUST_BACKTRACE=1 rustc test.rs
error: internal compiler error: Impl DefId { krate: 0, node: 7 }:Test.Add<i32, i32> was matchable against Obligation(trait_ref=<_ as core::ops::Add<_, _>>,depth=0) but now is not
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
task 'rustc' panicked at 'Box<Any>', /Users/rustbuild/src/rust-buildbot/slave/nightly-mac/build/src/libsyntax/diagnostic.rs:175

stack backtrace:
   1:        0x10a2997ff - rt::backtrace::imp::write::h41ac48e0092ef821Kqq
   2:        0x10a29c987 - failure::on_fail::h3381510cd10c9a61zHq
   3:        0x10a4f5495 - unwind::begin_unwind_inner::h8667451db5084e88EKd
   4:        0x109a88897 - unwind::begin_unwind::h574859237947728247
   5:        0x109a890d3 - diagnostic::Handler::bug::h6b8e7fd2f9430272TgG
   6:        0x10733a9c1 - middle::traits::select::SelectionContext<'cx, 'tcx>::rematch_impl::h88c48df6dbcc8ecfbkZ
   7:        0x1073294ab - middle::traits::select::SelectionContext<'cx, 'tcx>::confirm_candidate::h66ce271d2e7c254er0Y
   8:        0x107321837 - middle::traits::select::SelectionContext<'cx, 'tcx>::select::h1fe5e22ffd93df8bVuX
   9:        0x107320746 - middle::traits::fulfill::FulfillmentContext::select::hb3fa38b300468ae1f2W
  10:        0x10731ffbc - middle::traits::fulfill::FulfillmentContext::select_where_possible::hc2e2275050ef1b1eu1W
  11:        0x107235782 - middle::traits::fulfill::FulfillmentContext::select_all_or_error::h5af4c7aa23325766hZW
  12:        0x1074a1638 - middle::typeck::check::vtable::select_all_fcx_obligations_or_error::h2aa8ac2036bfa6468aO
  13:        0x1074f679b - middle::typeck::check::check_bare_fn::heec9ab1513e561178IV
  14:        0x1074f25dd - middle::typeck::check::check_item::h88a198c1ca5a907bh3V
  15:        0x1074f65df - middle::typeck::check::check_item_types::h153b2b615101bfcaiIV
  16:        0x106ffcbc6 - util::common::time::h7711944396490138833
  17:        0x1077bd73e - middle::typeck::check_crate::hd52e86e35ee1a30a3uo
  18:        0x10782696f - driver::driver::phase_3_run_analysis_passes::h340df4cdb996da5a8hB
  19:        0x107821198 - driver::driver::compile_input::h02967bf5608361a5TYA
  20:        0x10789fd3c - driver::run_compiler::h3ec9fe79d927cfd96OE
  21:        0x10789e1ce - driver::run::closure.145814
  22:        0x10701552b - task::TaskBuilder<S>::try_future::closure.104091
  23:        0x107015423 - task::TaskBuilder<S>::spawn_internal::closure.104062
  24:        0x106f93c7d - task::NativeSpawner.Spawner::spawn::closure.8516
  25:        0x10a55468c - rust_try_inner
  26:        0x10a554676 - rust_try
  27:        0x10a4f2c67 - unwind::try::h7be47cb819f03817Yyd
  28:        0x10a4f2afc - task::Task::run::hd977e1132c48b8d6LKc
  29:        0x106f93aa3 - task::NativeSpawner.Spawner::spawn::closure.8453
  30:        0x10a4f4327 - thread::thread_start::ha9ae96309fe3363b05c
  31:     0x7fff8c73d2fc - _pthread_body
  32:     0x7fff8c73d279 - _pthread_body

Apologies if this is an incorrect format or non-relevant, I've never really submitted a bug report to a large project before.

Addendum:
Adding "f64" to the second println!:

struct Test;

impl Add<i32, i32> for Test {
    fn add(&self, othr: &i32) -> i32 {
        othr + 1
    }
}

impl Add<f64, f64> for Test {
    fn add(&self, othr: &f64) -> f64 {
        othr + 2.0
    }
}

fn main() {
    let f = Test;
    println!("f + 3:   {}", f + 3);
    println!("f + 3.0: {}", f + 3.0f64);
}

compiles and runs as expected

[tyler@mac ~]$ ./test
f + 3:   4
f + 3.0: 5
@kmcallister kmcallister added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Jan 9, 2015
@steveklabnik
Copy link
Member

I tried to reproduce, but am bad at the Add trait. Once I updated the syntax for associated types, it failed with 'conflicting implementations.'

@paholg
Copy link

paholg commented Feb 4, 2015

@steveklabnik I believe I have reproduced this bug with associated types (or at least stumbled upon a very similar one).

use std::ops::Add;

trait Scalar {}
impl Scalar for f64 {}

struct Bob;

impl<RHS: Scalar> Add<RHS> for Bob {
    type Output = Bob;
    fn add(self, rhs: RHS) -> Bob { self }
}

fn main() {
    let b = Bob;
    b + 3.5;
    // Internal compiler error (should be type error?):
    b + 3;
}

playpen link

@veddan
Copy link
Contributor

veddan commented Apr 9, 2015

I ran into to it when accidentally using a float to index (&xs[5.] instead of &xs[5..]). However, copying the offending code verbatim to a new file didn't reproduce the error.

thread 'rustc' panicked at 'Box<Any>', /home/viktor/Documents/rust/rust/src/libsyntax/diagnostic.rs:191

stack backtrace:
1:      0x7fc4fb7689f8 - sys::backtrace::write::ha29d830caaf281c1kHC
2:      0x7fc4fb793f17 - panicking::on_panic::hd4b7cfa54ce15a47uUI
3:      0x7fc4fb6cba63 - rt::unwind::begin_unwind_inner::ha80e7d5af5095813CzI
4:      0x7fc4f8a6521d - rt::unwind::begin_unwind::h14288175298002166887
5:      0x7fc4f8a65972 - diagnostic::Handler::bug::hfe9a62f5ab542276osB
6:      0x7fc4f96a8ca1 - middle::traits::select::SelectionContext<'cx, 'tcx>::rematch_impl::h888ed2605974267aWuT
7:      0x7fc4f96a851f - middle::infer::InferCtxt<'a, 'tcx>::commit_if_ok::h8758431782731900545
8:      0x7fc4f96892ef - middle::traits::select::SelectionContext<'cx, 'tcx>::confirm_candidate::h680de60fb1bd61adSMS
9:      0x7fc4f965c86a - middle::traits::select::SelectionContext<'cx, 'tcx>::select::h105c655576bbde6e9NQ
10:     0x7fc4f966c33a - middle::traits::project::project_type::hf3dcf4dd73f443504tP
11:     0x7fc4f9669d71 - middle::traits::project::opt_normalize_projection_type::h72ea40d2d30b32b8GmP
12:     0x7fc4f9663e1a - middle::traits::project::poly_project_and_unify_type::closure.83715
13:     0x7fc4f9661ccc - middle::traits::project::poly_project_and_unify_type::h07927f85d5854b03P2O
14:     0x7fc4f965893b - middle::traits::fulfill::FulfillmentContext<'tcx>::select::h841d140980122122YEO
15:     0x7fc4f9657f2b - middle::traits::fulfill::FulfillmentContext<'tcx>::select_where_possible::h486388f4f6bf28bccEO
16:     0x7fc4fa3bdcb8 - check::vtable::select_fcx_obligations_where_possible::h9b2c69b3fe91faa2h4b
17:     0x7fc4fa3f622a - check::FnCtxt<'a, 'tcx>::resolve_type_vars_if_possible::h075b04892164c50b5Wo
18:     0x7fc4fa3a14b7 - check::structurally_resolved_type::h764154d1245e2f783xt
19:     0x7fc4fa4d0f9f - check::check_expr_with_unifier::h15570588596475525203
20:     0x7fc4fa47010a - check::op::check_binop::h97ec7d0b9e582ed693m
21:     0x7fc4fa4c7856 - check::check_expr_with_unifier::h11880991079361711379
22:     0x7fc4fa4c886e - check::check_expr_with_unifier::h11880991079361711379
23:     0x7fc4fa4af7a3 - check::check_expr_with_unifier::h13671224543324200731
24:     0x7fc4fa4990e8 - check::check_expr_with_unifier::check_then_else::hc4434b21966ece39ANq
25:     0x7fc4fa4c11f4 - check::check_expr_with_unifier::h1254672801148009773
26:     0x7fc4fa47e3f1 - check::check_block_with_expected::hf352b795571d241fUns
27:     0x7fc4fa4c13b3 - check::check_expr_with_unifier::h1254672801148009773
28:     0x7fc4fa3ad3de - check::_match::check_match::closure.28881
29:     0x7fc4fa3ad112 - check::_match::check_match::h2624ec058d33fc6aZmb
30:     0x7fc4fa4c1357 - check::check_expr_with_unifier::h1254672801148009773
31:     0x7fc4fa47e3f1 - check::check_block_with_expected::hf352b795571d241fUns
32:     0x7fc4fa4ce903 - check::check_expr_with_unifier::h15570588596475525203
33:     0x7fc4fa47e123 - check::check_block_with_expected::hf352b795571d241fUns
34:     0x7fc4fa45b969 - check::check_fn::haaf9eb020ec080d90Zn
35:     0x7fc4fa47905c - check::check_bare_fn::he93355dfc3534a69zPn
36:     0x7fc4fa472f24 - check::check_item::he0e731c9541337aak8n
37:     0x7fc4fa477662 - visit::walk_item::h16976416926307002031
38:     0x7fc4fa47766d - visit::walk_item::h16976416926307002031
39:     0x7fc4fa54c991 - check_crate::closure.36438
40:     0x7fc4fa546ed3 - check_crate::h60772f272ea0d698asC
41:     0x7fc4fbdea80d - driver::phase_3_run_analysis_passes::h71b6dad7a437d3fcgGa
42:     0x7fc4fbdce665 - driver::compile_input::h617a4fae1fdc397dQba
43:     0x7fc4fbe85c65 - run_compiler::h85ca2893f7ce8fe6S4b
44:     0x7fc4fbe8357d - boxed::F.FnBox<A>::call_box::h8037565825972556017
45:     0x7fc4fbe82ab9 - rt::unwind::try::try_fn::h15794509059050188955
46:     0x7fc4fb8109b8 - rust_try_inner
47:     0x7fc4fb8109a5 - rust_try
48:     0x7fc4fbe82d8b - boxed::F.FnBox<A>::call_box::h677285017824924912
49:     0x7fc4fb77ef01 - sys::thread::create::thread_start::he70b0e4e639cf402MuH
50:     0x7fc4f57cd0a3 - start_thread
51:     0x7fc4fb32d06c - clone
52:                0x0 - <unknown>

@tamird
Copy link
Contributor

tamird commented Apr 21, 2015

triage: still reproduces

@arielb1
Copy link
Contributor

arielb1 commented May 12, 2015

Duplicate of #24352

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

Successfully merging a pull request may close this issue.

8 participants