Closed
Description
Stumbled upon the following error when trying to box a trait where a inner lifetime (function) needs to be a subtype of an outer lifetime (trait)
playpen
code
trait Foo<'a> {
fn bar<'b>(&self, _: &'b u8)
where 'a: 'b
{
/* */
}
}
pub struct FooBar;
impl Foo<'static> for FooBar {}
fn test(foobar: FooBar) -> Box<Foo<'static>> {
Box::new(foobar)
}
rustc output
test.rs:1:1: 1:1 error: internal compiler error: Type parameter out of range when substituting in region 'b (root type=None) (space=FnSpace, index=0)
test.rs:1 trait Foo<'a> {
^
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
thread 'rustc' panicked at 'Box<Any>', ../src/libsyntax/diagnostic.rs:176
stack backtrace:
1: 0x7ffb665895ee - sys::backtrace::write::h04a6ced565b26815Lqs
2: 0x7ffb66591214 - panicking::on_panic::h521f84b604e22dfel8w
3: 0x7ffb6655404e - rt::unwind::begin_unwind_inner::hd3dee614a0e1c16cZNw
4: 0x7ffb638fcfdc - rt::unwind::begin_unwind::h16902420993434601027
5: 0x7ffb638fcf7b - diagnostic::SpanHandler::span_bug::he796b64f9a06f78eO4A
6: 0x7ffb64669e5b - middle::subst::SubstFolder<'a, 'tcx>.TypeFolder<'tcx>::fold_region::h824e080844b5206eqxP
7: 0x7ffb6544fd0a - iter::Map<I, F>.Iterator::next::h5056066582399914445
8: 0x7ffb6544d88e - trans::meth::emit_vtable_methods::closure.51812
9: 0x7ffb6544d377 - vec::Vec<T>.FromIterator<T>::from_iter::h17428483855504841875
10: 0x7ffb6544b5ca - trans::meth::get_vtable::closure.51758
11: 0x7ffb6544cdf4 - iter::FlatMap<I, U, F>.Iterator::next::h4997041961090004455
12: 0x7ffb6544cfbc - vec::Vec<T>::extend_desugared::h12545681854704529801
13: 0x7ffb6544c0a0 - iter::Iterator::collect::h17523528891276393804
14: 0x7ffb653b41f4 - trans::expr::unsized_info::h961a6a3ae2325378yIA
15: 0x7ffb653f1891 - trans::expr::coerce_unsized::h31652873fa02683flTA
16: 0x7ffb6533612c - trans::expr::trans::h541cacb4f6a005b5MAA
17: 0x7ffb653c4c22 - trans::expr::trans_into::h08f0184a4039fa63wuA
18: 0x7ffb65353035 - trans::controlflow::trans_block::h05d78924f32999a4Smv
19: 0x7ffb65351a36 - trans::base::trans_closure::hcbb7e42b32822a38R1h
20: 0x7ffb653535a7 - trans::base::trans_fn::hacbcaecdbf410a30pci
21: 0x7ffb6535646f - trans::base::trans_item::he017b8b1980c8d10vAi
22: 0x7ffb65363618 - trans::base::trans_crate::h37b278a44ad52ceasoj
23: 0x7ffb66af24be - driver::phase_4_translate_to_llvm::hb64c06949a503dda2Oa
24: 0x7ffb66aed066 - driver::phase_3_run_analysis_passes::closure.15783
25: 0x7ffb66ae8633 - middle::ty::ctxt<'tcx>::create_and_enter::h349256048753845929
26: 0x7ffb66ae3a17 - driver::phase_3_run_analysis_passes::h15521018079403107052
27: 0x7ffb66ac6266 - driver::compile_input::hbf698b02349f7ce3Tba
28: 0x7ffb66b9fed3 - run_compiler::hd724b5fef3441688y7b
29: 0x7ffb66b9d8ae - boxed::F.FnBox<A>::call_box::h6609070342514802751
30: 0x7ffb66b9d0f9 - rt::unwind::try::try_fn::h10774555836369096370
31: 0x7ffb6660ad48 - rust_try_inner
32: 0x7ffb6660ad35 - rust_try
33: 0x7ffb6657c8a7 - rt::unwind::try::inner_try::hb0d7a3eb324339ceSJw
34: 0x7ffb66b9d30b - boxed::F.FnBox<A>::call_box::h18179817771297192954
35: 0x7ffb6658fe71 - sys::thread::Thread::new::thread_start::hf8c7448e27294ed0PTv
36: 0x7ffb601b90a4 - start_thread
37: 0x7ffb661dacfc - clone
38: 0x0 - <unknown>
rustc version
rustc 1.3.0-nightly (bf3c979ec 2015-06-30)
binary: rustc
commit-hash: bf3c979ec31300e38c1607d605cf47f231bf6480
commit-date: 2015-06-30
host: x86_64-unknown-linux-gnu
release: 1.3.0-nightly