Closed
Description
Summary
When T
is not : 'static
, calling a function of signature
fn foo<T> (_: &'_ T)
where
for<'a> &'a T : Trait<AssociatedType = &'a ()>,
{}
leads to an ICE.
Steps to reproduce
trait Trait {
type AssociatedType;
}
impl<'a, T : 'a> Trait for &'a T {
type AssociatedType = &'a ();
}
/// Calling this with some T when we don't have `T : 'static` leads to an ICE
fn foo<T> (_: &'_ T)
where
for<'a> &'a T : Trait<AssociatedType = &'a ()>,
{}
/// proof
fn main ()
{
use ::core::convert::identity as force_local;
match force_local(()) { ref not_static => {
foo(¬_static);
}}
}
Tested on
-
1.33.0 nightly and stable
-
1.34.1 stable
-
1.36.0 nightly
ICE Backtrace
thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', src/libcore/option.rs:347:21
stack backtrace:
0: 0x7f017a77edf3 - std::sys::unix::backtrace::tracing::imp::unwind_backtrace::haf1a3ee7aa81178f
at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
1: 0x7f017a776c7b - std::sys_common::backtrace::_print::h4025758c54fa4159
at src/libstd/sys_common/backtrace.rs:71
2: 0x7f017a77b056 - std::panicking::default_hook::{{closure}}::h402d67f0ee8abb93
at src/libstd/sys_common/backtrace.rs:59
at src/libstd/panicking.rs:197
3: 0x7f017a77ade9 - std::panicking::default_hook::h5927269e5fe05d46
at src/libstd/panicking.rs:211
4: 0x7f0177ae46f0 - rustc::util::common::panic_hook::hd3479589b6652967
5: 0x7f017a77b848 - std::panicking::rust_panic_with_hook::hd291985d6b07ecab
at src/libstd/panicking.rs:478
6: 0x7f017a77b2e1 - std::panicking::continue_panic_fmt::h2ef8bba7dd53e0f9
at src/libstd/panicking.rs:381
7: 0x7f017a77b1c5 - rust_begin_unwind
at src/libstd/panicking.rs:308
8: 0x7f017a7a419c - core::panicking::panic_fmt::h4c9bb56fb9570ecd
at src/libcore/panicking.rs:85
9: 0x7f017a7a40db - core::panicking::panic::hf6c74ec97f800281
at src/libcore/panicking.rs:49
10: 0x7f017850adcf - rustc_mir::borrow_check::nll::region_infer::error_reporting::<impl rustc_mir::borrow_check::nll::region_infer::RegionInferenceContext>::free_region_constraint_info::hcd94121a44194da1
11: 0x7f01785a3cb7 - rustc_mir::borrow_check::nll::explain_borrow::<impl rustc_mir::borrow_check::MirBorrowckCtxt>::explain_why_borrow_contains_point::h0259947006b8657a
12: 0x7f0178599c8e - rustc_mir::borrow_check::error_reporting::<impl rustc_mir::borrow_check::MirBorrowckCtxt>::report_borrowed_value_does_not_live_long_enough::h2d9384c7c69018d4
13: 0x7f01785b174f - rustc_mir::borrow_check::MirBorrowckCtxt::check_for_invalidation_at_exit::h0d8d2b2111d9852b
14: 0x7f017878e44d - rustc_mir::borrow_check::flows::Flows::with_outgoing_borrows::h59cb62c081661925
15: 0x7f01785af4a1 - <rustc_mir::borrow_check::MirBorrowckCtxt as rustc_mir::dataflow::DataflowResultsConsumer>::visit_terminator_entry::he99447d412888dea
16: 0x7f01785ab31b - rustc_mir::borrow_check::do_mir_borrowck::he1e08ebff5e85c4c
17: 0x7f017865a98b - rustc::ty::context::GlobalCtxt::enter_local::h76697e7495d5de01
18: 0x7f01785a74b3 - rustc_mir::borrow_check::mir_borrowck::hd2a7c2c2a29481ea
19: 0x7f0179a2dde6 - rustc::ty::query::__query_compute::mir_borrowck::h0482b255069ce6d0
20: 0x7f017995fc24 - rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::mir_borrowck>::compute::h7d9d10d43f88afb6
21: 0x7f017995b350 - rustc::dep_graph::graph::DepGraph::with_task_impl::hd7a0b24f50278d9e
22: 0x7f01799781db - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query::hbbcee6dbee76d90c
23: 0x7f017995fac2 - rustc::ty::<impl rustc::ty::context::TyCtxt>::par_body_owners::h89025f102a55b2f6
24: 0x7f0179a62257 - rustc::util::common::time::h3c154293cf490d17
25: 0x7f01799a14be - rustc_interface::passes::analysis::h8f84f9aac031a1ef
26: 0x7f017aa42b45 - rustc::ty::query::__query_compute::analysis::hf86c5ce02b4262be
27: 0x7f017aa94608 - rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::analysis>::compute::h8c5d64a327c7fda7
28: 0x7f017aa6635c - rustc::dep_graph::graph::DepGraph::with_task_impl::h18baf177dba4f515
29: 0x7f017aa95fb4 - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query::h888080c742ef1585
30: 0x7f017aa43165 - rustc::ty::context::tls::enter_global::hec5e5d04ebea1ec5
31: 0x7f017aa5a586 - rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}::h76370eccdcbe3781
32: 0x7f01799e1c24 - rustc_interface::passes::create_global_ctxt::{{closure}}::h643f79b7fa277823
33: 0x7f017aa5b8e9 - rustc_interface::interface::run_compiler_in_existing_thread_pool::h03fd2a673a112391
34: 0x7f017aadb703 - std::thread::local::LocalKey<T>::with::hb4bfbaa8ed9297fa
35: 0x7f017aaa29e4 - scoped_tls::ScopedKey<T>::set::h8b358cd22c3a6454
36: 0x7f017aad6f4f - syntax::with_globals::h89e65f9b0993082f
37: 0x7f017aa35169 - std::sys_common::backtrace::__rust_begin_short_backtrace::he0297bc984d9026c
38: 0x7f017a78c619 - __rust_maybe_catch_panic
at src/libpanic_unwind/lib.rs:85
39: 0x7f017aa4fde8 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h734d38892498b477
40: 0x7f017a75d75e - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::hc7a06d37461455da
at /rustc/3991285f55a4b7cd92b7ffcdc396a3023076f5cb/src/liballoc/boxed.rs:704
41: 0x7f017a78b28f - std::sys::unix::thread::Thread::new::thread_start::ha74a24b94eca0f79
at /rustc/3991285f55a4b7cd92b7ffcdc396a3023076f5cb/src/liballoc/boxed.rs:704
at src/libstd/sys_common/thread.rs:13
at src/libstd/sys/unix/thread.rs:79
42: 0x7f017a4fc6b9 - start_thread
43: 0x7f0179e2641c - clone
44: 0x0 - <unknown>
query stack during panic:
#0 [mir_borrowck] processing `main`
#1 [analysis] running analysis passes on this crate
end of query stack
Hypothesis
Maybe rustc
does not add the implicit
for<'a> T : 'a
bound required for the other bound to make sense