Closed
Description
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