Closed
Description
- I tried this code:
trait Stringify {
fn to_string(&self) -> String;
}
impl Stringify for u32 {
fn to_string(&self) -> String { format!("u32: {}", *self) }
}
impl Stringify for f32 {
fn to_string(&self) -> String { format!("f32: {}", *self) }
}
fn print<T: Stringify>(x: T) {
println!("{}", x.to_string());
}
fn main() {
print(5);
print(5.0);
}
- I expected to see this happen:
u32: 5
f32: 5.0
- Instead, this happened:
error: internal compiler error: Impl DefId { krate: 0, node: 12 }:u32.Stringify was matchable against Obligation(predicate=Binder(TraitPredicate(Stringify)),depth=0) 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
Meta
rustc 1.0.0-nightly (199bdcf 2015-03-26) (built 2015-03-26)
binary: rustc
commit-hash: 199bdcf
commit-date: 2015-03-26
build-date: 2015-03-26
host: x86_64-apple-darwin
release: 1.0.0-nightly
- Backtrace:
thread 'rustc' panicked at 'Box<Any>', /Users/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-mac/build/src/libsyntax/diagnostic.rs:190
stack backtrace:
1: 0x10cdac8b4 - sys::backtrace::write::h56b628caa3d9f4e2WBD
2: 0x10cdd7a08 - panicking::on_panic::ha7bc09956d9f12916rJ
3: 0x10ccf499e - rt::unwind::begin_unwind_inner::h5ef900798574fe5egaJ
4: 0x10c4ec45e - rt::unwind::begin_unwind::h2748891250859470333
5: 0x10c4ecc89 - diagnostic::Handler::bug::h57426bf76a5037d4pgB
6: 0x10a06b4bf - middle::traits::select::SelectionContext<'cx, 'tcx>::rematch_impl::h3b4e834c3872ae21NVR
7: 0x10a06ab56 - middle::infer::InferCtxt<'a, 'tcx>::try::h6881848181392734290
8: 0x10a0510c4 - middle::traits::select::SelectionContext<'cx, 'tcx>::confirm_candidate::ha7bb241f7d3cdb480iR
9: 0x10a025b8d - middle::traits::select::SelectionContext<'cx, 'tcx>::select::hb97262a482e0a260koP
10: 0x10a0225e0 - middle::traits::fulfill::FulfillmentContext<'tcx>::select::hcffa8f4e81b26cc8HhN
11: 0x10a021aee - middle::traits::fulfill::FulfillmentContext<'tcx>::select_where_possible::h0a2ed0d6733c5352VgN
12: 0x10942d473 - check::vtable::select_fcx_obligations_where_possible::h796cff45179b9501A4b
13: 0x10942cfc3 - check::vtable::select_all_fcx_obligations_and_apply_defaults::hfadb66c912bf39a2X0b
14: 0x1094de47e - check::check_bare_fn::heb3c8094aebf74083nn
15: 0x1094d68eb - check::check_item::h25c21617996c325dOGn
16: 0x1095afed6 - check_crate::closure.35998
17: 0x1095aad9a - check_crate::haa845b167eb64ccfOmC
18: 0x1092e4477 - driver::phase_3_run_analysis_passes::h8f332883f9aa5c0arGa
19: 0x1092ca4b7 - driver::compile_input::h0311d7070ac04983Rba
20: 0x109384093 - run_compiler::hbe451b463527cb69s2b
21: 0x109381bb5 - thunk::F.Invoke<A, R>::invoke::h777505636365567823
22: 0x109380f77 - rt::unwind::try::try_fn::h5237749675862334843
23: 0x10ce5dfa8 - rust_try_inner
24: 0x10ce5df95 - rust_try
25: 0x109381315 - thunk::F.Invoke<A, R>::invoke::h424791141543398798
26: 0x10cdc299d - sys::thread::create::thread_start::h760927331a49c0e267H
27: 0x7fff91d6b267 - _pthread_body
28: 0x7fff91d6b1e4 - _pthread_start