Skip to content

ICE: Impl was matchable against Obligation(...) but now is not #22645

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

Closed
honzasp opened this issue Feb 21, 2015 · 4 comments · Fixed by #25344
Closed

ICE: Impl was matchable against Obligation(...) but now is not #22645

honzasp opened this issue Feb 21, 2015 · 4 comments · Fixed by #25344
Labels
A-trait-system Area: Trait system I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@honzasp
Copy link

honzasp commented Feb 21, 2015

I got an internal compiler error when cargo testing my code, and I was unfortunately unable to reproduce on a small sample. The code is here on Github, to reproduce the error, change the literal on one line in test from 42.0 to 42.

$ rustc --version --verbose
rustc 1.0.0-nightly (522d09dfe 2015-02-19) (built 2015-02-21)
binary: rustc
commit-hash: 522d09dfecbeca1595f25ac58c6d0178bbd21d7d
commit-date: 2015-02-19
build-date: 2015-02-21
host: i686-unknown-linux-gnu
release: 1.0.0-nightly
$ RUST_BACKTRACE=1 cargo test --verbose
   Compiling spiral v0.0.1 (file:///[...]/spiral)
     Running `rustc src/main.rs --crate-name spiral --crate-type bin -g --test -C metadata=1ade813d3d860ac1 -C extra-filename=-1ade813d3d860ac1 --out-dir [...]/spiral/target --emit=dep-info,link -L dependency=[...]/spiral/target -L dependency=[...]/spiral/target/deps`
error: internal compiler error: Impl DefId { krate: 2, node: 74181 } was matchable against Obligation(predicate=Binder(TraitPredicate(core::cmp::PartialEq<_>)),depth=1) but now is not
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:189

stack backtrace:
   1: 0xb7231280 - sys::backtrace::write::hb58c665617e5cee2KlC
   2: 0xb725b8b0 - panicking::on_panic::hd4d4fc652390cdd8tXL
   3: 0xb7195ac0 - rt::unwind::begin_unwind_inner::h6797c7a781aac698RBL
   4: 0xb5656fd0 - rt::unwind::begin_unwind::h13117811778590822301
   5: 0xb5657800 - diagnostic::Handler::bug::h0b9167776bd8dc1aw4E
   6: 0xb61b5310 - middle::traits::select::SelectionContext<'cx, 'tcx>::rematch_impl::h7f3f2e654c4ffad9kHU
   7: 0xb61b4c30 - middle::infer::InferCtxt<'a, 'tcx>::try::h13523729267676866609
   8: 0xb619dd90 - middle::traits::select::SelectionContext<'cx, 'tcx>::confirm_candidate::ha4efb7af28b19263S8T
   9: 0xb61784f0 - middle::traits::select::SelectionContext<'cx, 'tcx>::select::h5394e35b0e7c70a6lhS
  10: 0xb6174160 - middle::traits::fulfill::FulfillmentContext<'tcx>::select::hbef8233dc9336219B0P
  11: 0xb6173ac0 - middle::traits::fulfill::FulfillmentContext<'tcx>::select_where_possible::hbd71b9b88c61613cHZP
  12: 0xb6cdddc0 - check::vtable::select_fcx_obligations_where_possible::hffd3ec74dffa624eVRb
  13: 0xb6d1a6f0 - check::FnCtxt<'a, 'tcx>::resolve_type_vars_if_possible::he1da80c3c9c1dda2rJo
  14: 0xb6cca360 - check::structurally_resolved_type::hb6535b94e7bbe37bNPt
  15: 0xb6e00220 - check::check_expr_with_unifier::h9614455191220309796
  16: 0xb6dbad90 - check::check_expr_with_unifier::check_binop::hbf8de0ab08b2ba09JMq
  17: 0xb6df3370 - check::check_expr_with_unifier::h6092115828992963581
  18: 0xb6dd9240 - check::check_expr_with_unifier::h3884107362083173097
  19: 0xb6dbad90 - check::check_expr_with_unifier::check_binop::hbf8de0ab08b2ba09JMq
  20: 0xb6df3370 - check::check_expr_with_unifier::h6092115828992963581
  21: 0xb6df3370 - check::check_expr_with_unifier::h6092115828992963581
  22: 0xb6dd9240 - check::check_expr_with_unifier::h3884107362083173097
  23: 0xb6dd0200 - check::check_expr_with_unifier::check_then_else::h483da0d6a4f3eab2MEq
  24: 0xb6decc20 - check::check_expr_with_unifier::h17365000147061483630
  25: 0xb6da6d80 - check::check_block_with_expected::hf29cd5d4f1823991zys
  26: 0xb6decc20 - check::check_expr_with_unifier::h17365000147061483630
  27: 0xb6ccafe0 - check::_match::check_match::closure.29042
  28: 0xb6ccac10 - check::_match::check_match::h77807f1365a779d3V1a
  29: 0xb6decc20 - check::check_expr_with_unifier::h17365000147061483630
  30: 0xb6da6d80 - check::check_block_with_expected::hf29cd5d4f1823991zys
  31: 0xb6df9ad0 - check::check_expr_with_unifier::h14838318111108599859
  32: 0xb6da6d80 - check::check_block_with_expected::hf29cd5d4f1823991zys
  33: 0xb6d85a80 - check::check_fn::h9733b23b5bb31869JKn
  34: 0xb6da3700 - check::check_bare_fn::hc0a904b0aabec0a4Wzn
  35: 0xb6d9aa00 - check::check_item::heaa17bb09891b8a9nTn
  36: 0xb6da19f0 - visit::walk_item::h334270929839752142
  37: 0xb6da19f0 - visit::walk_item::h334270929839752142
  38: 0xb6da19f0 - visit::walk_item::h334270929839752142
  39: 0xb6e7f750 - check_crate::closure.35867
  40: 0xb6e78b60 - check_crate::h74f1efb9c9ad0cecVjC
  41: 0xb769c480 - driver::phase_3_run_analysis_passes::ha81485be033381d8gHa
  42: 0xb7680c20 - driver::compile_input::h55e2c5089100dcc0Gba
  43: 0xb7760430 - run_compiler::h7c1df0ae32ef6a57Zbc
  44: 0xb775e810 - thunk::F.Invoke<A, R>::invoke::h4956589150906656218
  45: 0xb775d680 - rt::unwind::try::try_fn::h3108213307196454525
  46: 0xb72d5b30 - rust_try_inner
  47: 0xb72d5b00 - rust_try
  48: 0xb775d9b0 - thunk::F.Invoke<A, R>::invoke::h9387302087009601825
  49: 0xb72474c0 - sys::thread::thread_start::hb380b1da46a95e5393G
  50: 0xb2f29ea0 - start_thread
  51: 0xb7049502 - clone
  52:        0x0 - <unknown>

Could not compile `spiral`.

Caused by:
  Process didn't exit successfully: `rustc src/main.rs --crate-name spiral --crate-type bin -g --test -C metadata=1ade813d3d860ac1 -C extra-filename=-1ade813d3d860ac1 --out-dir [...]/spiral/target --emit=dep-info,link -L dependency=[...]/spiral/target -L dependency=[...]/spiral/target/deps` (status=101)

I am sorry for such a crude report, but I could not come with a better sample, as the origin of the error is a bit unclear to me.

@kmcallister kmcallister added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ A-trait-system Area: Trait system labels Feb 21, 2015
@edwardw
Copy link
Contributor

edwardw commented Feb 22, 2015

There seems to be at least four similar tickets about this "but now is not" business: this one, #19976, #18623, #18954. They could be all dups.

@tamird
Copy link
Contributor

tamird commented Apr 21, 2015

Agree with @edwardw. Either way, this does still repro with:

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 {} # this is not even valid
}

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

@TimNN
Copy link
Contributor

TimNN commented Apr 24, 2015

I think #23825 is also a dupe of this.

The following code reproduces the same issue:

fn main() {
    let a: f32 = 0f32 * 0.0;
    a * 0;
}

Note that even though a is explicitly typed, this still causes the ICE.

@arielb1
Copy link
Contributor

arielb1 commented May 12, 2015

Duplicate of #24352

arielb1 pushed a commit to arielb1/rust that referenced this issue May 12, 2015
There is no subtyping relationship between the types (or their non-freshened
variants), so they can not be merged.

Fixes rust-lang#22645
Fixes rust-lang#24352
Fixes rust-lang#23825

Should fix rust-lang#25235 (no test in issue).
Should fix rust-lang#19976 (test is outdated).
bors added a commit that referenced this issue May 13, 2015
There is no subtyping relationship between the types (or their non-freshened
variants), so they can not be merged.

Fixes #22645
Fixes #24352
Fixes #23825

Should fix #25235 (no test in issue).
Should fix #19976 (test is outdated).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-trait-system Area: Trait system 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.

7 participants