How can I tell the compiler to shut up and accept a value as if it lived for 'static, no matter the requirements on type parameters? How could I get the example below to work?
use std::mem::transmute;
struct Foo<'a, T: 'a>(&'a T);
fn take_foo<'a, T: 'a>(x : Foo<'a, T>) {
// How can I lie here and claim f lives for 'static?
need_static(x)
// This doesn't work.
//need_static(transmute::<Foo<'a, T>, Foo<'static, T>>(x))
}
fn need_static<T: 'static>(_:T) {}
Unfortunately, it's impossible to have &'static T where T is not : 'static. That limitation is the motivation for 'unsafe lifetime RFC (although it wouldn't help in this exact case either).
The real use case was trying to upgrade rayon to futures 0.0.14 and get rid of the Unpark trait object in the process. Futures wants an Arc<T: Unpark + 'static> but rayon has
Ah, yeah, becoming a trait object is part of how it can lie about the lifetimes. For other's reference, that's in make_unpark.
Which futures API are you talking about though? Because I thought most of it already takes Arc<Unpark>, a trait object, so I'm not sure what you're trying to avoid. But since Unpark is deprecated, we should see if the new Notify helps the situation.