Open
Description
This code compiles with the comments and does not compile without the comments.
fn main() {
fn subparsing_lifetime<'s, 'r>(args: &'s Vec<&'s str>) -> (&'r ()/*, &'s ()*/) { unreachable!() }
let closure = |args| subparsing_lifetime(&args);
}
It runs in the compiler error "cannot return value referencing function parameter".
This highlights, to me, suboptimal interaction between the lifetime oriented type system and the value oriented type system.
The typing guarantees that the function parameter is not referenced in the values.
Moreover, there are use cases, bumpalo arenas, for instance, where it is perfectly legitimate to have lifetimes shared between arguments and returned values, with no dependencies between one and the other.
So this code should compile if uncommented.
One of the interest I have in rust is precisely the ability to share lifetimes between independent references.