Yeah once actual type generics are involved in the existential, the properties are weird: I've noticed a returned existential doesn't need the Captures
hack for those, so I suspect an existential is always generic over the type parameters in scope; this also makes it so that we are back to a "compositionality" of bounds that, similar to (T, impl 'b)
, actually yields an item which, as a whole, is globally not necessarily able to outlive 'b
. I'd personally qualify that as a bug, since it does go against the intuition that an impl …
item does indeed always meet all of the …
bounds.
The silliest example I know of this property is the following snippet:
fn identity_or_is_it<'lt : 'lt> (
it: impl FnOnce(&'lt ()) + 'static,
) -> impl FnOnce(&'lt ()) + 'static
{
it
}
fn main<'not_static> ()
{
fn f(_: &()) {}
let f = identity_or_is_it::<'not_static>(f); // OK
let f = identity_or_is_it::<'not_static>(f); // Errors!??
}