Closed
Description
This code causes Rust to ICE on stable, beta, and nightly.
pub trait Reborrow<'a, 'b>
where
Self: 'a,
'a: 'b,
{
type Output: 'b;
fn reborrow(self) -> Self::Output;
}
impl<'a, 'b, T> Reborrow<'a, 'b> for &'a mut T
where
'a: 'b,
{
type Output = &'b mut T;
fn reborrow(self) -> Self::Output {
&mut *self
}
}
impl<'a, 'b, T: Copy> Reborrow<'a, 'b> for T {
type Output = Self;
fn reborrow(self) -> Self::Output {
self
}
}
fn main() {}
It is specifically the second impl (the one with the Copy
bound) that causes the ICE.
Backtrace
thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', libcore/option.rs:335:21
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
1: std::sys_common::backtrace::print
2: std::panicking::default_hook::{{closure}}
3: std::panicking::default_hook
4: std::panicking::rust_panic_with_hook
5: std::panicking::begin_panic
6: std::panicking::begin_panic_fmt
7: rust_begin_unwind
8: core::panicking::panic_fmt
9: core::panicking::panic
10: <std::thread::local::LocalKey<T>>::with
11: rustc::ty::context::GlobalCtxt::enter_local
12: rustc::traits::coherence::overlapping_impls
13: rustc::traits::specialize::specialization_graph::Graph::insert
14: rustc::traits::specialize::specialization_graph_provider
15: rustc::dep_graph::graph::DepGraph::with_task_impl
16: rustc_errors::Handler::track_diagnostics
17: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::cycle_check
18: rustc::ty::maps::<impl rustc::ty::maps::queries::specialization_graph_of<'tcx>>::force
19: rustc::ty::maps::<impl rustc::ty::maps::queries::specialization_graph_of<'tcx>>::try_get
20: rustc::ty::maps::TyCtxtAt::specialization_graph_of
21: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::specialization_graph_of
22: rustc_typeck::coherence::coherent_trait
23: rustc::dep_graph::graph::DepGraph::with_task_impl
24: rustc_errors::Handler::track_diagnostics
25: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::cycle_check
26: rustc::ty::maps::<impl rustc::ty::maps::queries::coherent_trait<'tcx>>::force
27: rustc::ty::maps::<impl rustc::ty::maps::queries::coherent_trait<'tcx>>::try_get
28: rustc::ty::maps::TyCtxtAt::coherent_trait
29: rustc::ty::maps::<impl rustc::ty::maps::queries::coherent_trait<'tcx>>::ensure
30: rustc_typeck::coherence::check_coherence
31: rustc_typeck::check_crate
32: <std::thread::local::LocalKey<T>>::with
33: <std::thread::local::LocalKey<T>>::with
34: rustc::ty::context::TyCtxt::create_and_enter
35: rustc_driver::driver::compile_input
36: rustc_driver::run_compiler
Tested on rustc 1.23.0 (766bd11c8 2018-01-01)
, rustc 1.25.0-beta.7 (da64ca931 2018-03-03)
, and rustc 1.26.0-nightly (e026b59cf 2018-03-03)