Closed
Description
Compiler panicks instead of showing an appropriate error message in case boundaries are not satisfied.
I tried this code:
https://gist.github.com/dnsl48/d3a4a380a24e1f25ff220540cebd9806#file-source-rs
pub struct Word;
pub struct Pointer<'a> {
val: &'a Word
}
impl<'a> Pointer<'a> {
pub fn into<T> (self) -> Option<T>
where &'a Word: Into<Result<T, &'a Word>>
{
let result: Result<T, _> = self.val.into ();
result.ok ()
}
}
pub trait FromPointer<'a>: Sized {
fn from_pointer (Pointer<'a>) -> Option<Self>;
}
impl<'a> FromPointer<'a> for u8 where &'a Word: Into<Result<u8, &'a Word>> {
fn from_pointer (pointer: Pointer<'a>) -> Option<Self> { pointer.into::<u8> () }
}
fn main() { }
In the result compiler panicked with the following message:
https://gist.github.com/dnsl48/d3a4a380a24e1f25ff220540cebd9806#file-error
error: internal compiler error: ../src/librustc/infer/mod.rs:699: Encountered errors `[FulfillmentError(Obligation(predicate=Binder(TraitPredicate(<std::result::Result<u8, &Word> as std::convert::From<&Word>>)),depth=1),Unimplemented)]` resolving bounds after type-checking
note: the compiler unexpectedly panicked. this is a bug.
Meta
$ rustc --version --verbose
rustc 1.13.0 (2c6933acc 2016-11-07)
binary: rustc
commit-hash: 2c6933acc05c61e041be764cb1331f6281993f3f
commit-date: 2016-11-07
host: x86_64-unknown-linux-gnu
release: 1.13.0
Backtrace:
thread 'rustc' panicked at 'Box<Any>', ../src/librustc_errors/lib.rs:602
stack backtrace:
1: 0x7ff032d0985f - std::sys::backtrace::tracing::imp::write::h6f1d53a70916b90d
2: 0x7ff032d18dbd - std::panicking::default_hook::{{closure}}::h137e876f7d3b5850
3: 0x7ff032d1622e - std::panicking::default_hook::h0ac3811ec7cee78c
4: 0x7ff032d16918 - std::panicking::rust_panic_with_hook::hc303199e04562edf
5: 0x7ff031878378 - std::panicking::begin_panic::hf3c77cb5fd5814c4
6: 0x7ff03196ddf5 - rustc::session::opt_span_bug_fmt::{{closure}}::hf0e25c590c479ec5
7: 0x7ff03189685a - rustc::session::span_bug_fmt::h42d4c0a219d5e4ec
8: 0x7ff0319740e2 - rustc_trans::common::fulfill_obligation::{{closure}}::{{closure}}::hb19019dff3d27900
9: 0x7ff031908802 - rustc_trans::common::fulfill_obligation::hc5c403d8dc435d27
10: 0x7ff031902718 - rustc_trans::collector::do_static_dispatch::h70f77266775460b2
11: 0x7ff031901b49 - <rustc_trans::collector::MirNeighborCollector<'a, 'tcx> as rustc::mir::visit::Visitor<'tcx>>::visit_operand::hcb81ecfa21b561eb
12: 0x7ff031902459 - <rustc_trans::collector::MirNeighborCollector<'a, 'tcx> as rustc::mir::visit::Visitor<'tcx>>::visit_terminator_kind::h3f9e14a5cd0a0cbd
13: 0x7ff031891995 - rustc::mir::visit::Visitor::visit_mir::h06603f079eadd52e
14: 0x7ff0318ffb32 - rustc_trans::collector::collect_items_rec::h58706c6ceb59a24d
15: 0x7ff031900692 - rustc_trans::collector::collect_items_rec::h58706c6ceb59a24d
16: 0x7ff0319713b2 - rustc_trans::base::collect_and_partition_translation_items::{{closure}}::h3a209f998241a340
17: 0x7ff0318e6518 - rustc_trans::base::collect_and_partition_translation_items::h26e28c343e8a4a22
18: 0x7ff0318e0c4c - rustc_trans::base::trans_crate::h7b6c2eb43ae0c1da
19: 0x7ff03309aa0d - rustc_driver::driver::phase_4_translate_to_llvm::h0646ffc4a1716d29
20: 0x7ff0330d5e2a - rustc_driver::driver::compile_input::{{closure}}::h5a81b1e8a8f3f531
21: 0x7ff0330c16a3 - rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}::h4091eeab6f271a29
22: 0x7ff0330983ad - rustc_driver::driver::phase_3_run_analysis_passes::hff1c31d493acfd09
23: 0x7ff033084a39 - rustc_driver::driver::compile_input::hef221f9f618e92f5
24: 0x7ff0330af206 - rustc_driver::run_compiler::h7dddd4089f8330b4
25: 0x7ff032feb2c3 - std::panicking::try::do_call::h1e3ece12e3f812df
26: 0x7ff032d20cb6 - __rust_maybe_catch_panic
27: 0x7ff0330094f9 - <F as alloc::boxed::FnBox<A>>::call_box::h05b222e46803eb30
28: 0x7ff032d14c80 - std::sys::thread::Thread::new::thread_start::h759e10bc4abc7e72
29: 0x7ff02bc89453 - start_thread
30: 0x7ff0329e57de - __GI___clone
31: 0x0 - <unknown>