Closed
Description
I was incrementally trying to define a trait for Peekable on playpen. When compiling an intermediate and unbalanced version of the code, I ended up with a rustc panic. The code is the following:
use std::iter::{Iterator,Peekable};
trait PeekableTrait {
type Item;
fn peek(&mut self) -> Option<&<Self as Iterator>::Item> where Self: Iterator;
}
impl<I: Iterator> PeekableTrait for Peekable<I> {
type Item = I::Item;
fn peek(&mut self) -> Option<&Self::Item> where Self: Iterator {
}
}
(This is obviously incomplete code, but it crashes rustc)
The panic looks like:
error: internal compiler error: unexpected panic
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 'called `Option::unwrap()` on a `None` value', ../src/libcore/option.rs:326
stack backtrace:
1: 0x7ff0e7a43629 - std::sys::backtrace::tracing::imp::write::h482d45d91246faa2
2: 0x7ff0e7a53d1c - std::panicking::default_hook::_{{closure}}::h89158f66286b674e
3: 0x7ff0e7a52027 - std::panicking::default_hook::h9e30d428ee3b0c43
4: 0x7ff0e7a52838 - std::panicking::rust_panic_with_hook::h2224f33fb7bf2f4c
5: 0x7ff0e7a526d2 - std::panicking::begin_panic::hcb11a4dc6d779ae5
6: 0x7ff0e7a52600 - std::panicking::begin_panic_fmt::h310416c62f3935b3
7: 0x7ff0e7a52581 - rust_begin_unwind
8: 0x7ff0e7abdaef - core::panicking::panic_fmt::hc5789f4e80194729
9: 0x7ff0e7abda1b - core::panicking::panic::h1953378f4b37b561
10: 0x7ff0e6133f3c - rustc_typeck::check::compare_method::compare_impl_method::_{{closure}}::h08bef90d287aed42
11: 0x7ff0e6090099 - rustc_typeck::check::compare_method::compare_impl_method::he3538453c2efe177
12: 0x7ff0e60a4de2 - rustc_typeck::check::check_impl_items_against_trait::hb105ca8bb42a0b3d
13: 0x7ff0e60a25a2 - rustc_typeck::check::check_item_type::hba3733559d49be1e
14: 0x7ff0e609adeb - _<rustc_typeck..check..CheckItemTypesVisitor<'a, 'tcx> as rustc..hir..intravisit..Visitor<'tcx>>::visit_item::h369cacffbaa18923
15: 0x7ff0e609cceb - rustc_typeck::check::check_item_types::h81e44a5d40f450fd
16: 0x7ff0e6114323 - rustc_typeck::check_crate::h8ec8b2f490f5dc28
17: 0x7ff0e7e32b03 - rustc_driver::driver::phase_3_run_analysis_passes::_{{closure}}::h45e03cee16dcf298
18: 0x7ff0e7dff546 - rustc_driver::driver::phase_3_run_analysis_passes::hc0de40cea97d81a1
19: 0x7ff0e7debf02 - rustc_driver::driver::compile_input::hd9ecc57abd3cba85
20: 0x7ff0e7e1e756 - rustc_driver::run_compiler::h184264500271cc39
21: 0x7ff0e7d648c2 - std::panicking::try::do_call::h17a7a17ad7240c5c
22: 0x7ff0e7a62086 - __rust_maybe_catch_panic
23: 0x7ff0e7d7e26a - _<F as alloc..boxed..FnBox<A>>::call_box::h93f9128277b2964a
24: 0x7ff0e7a503f2 - std::sys::thread::Thread::new::thread_start::he0bf102845911132
25: 0x7ff0dfd656f9 - start_thread
26: 0x7ff0e7693b5c - clone
27: 0x0 - <unknown>
The panic doesn't happen when both the trait and the impl use either Option<&Self::Item>
(which yields a normal compilation error) or Option<&<Self as Iterator>::Item>
.
This only happens on nightly on playpen, not on stable or beta.
Metadata
Metadata
Assignees
Labels
No labels