Suboptimal interaction between lifetime oriented and value oriented type system in the presence of closures. #125250
Labels
A-lifetimes
Area: lifetime related
C-discussion
Category: Discussion or questions that doesn't represent real issues.
S-has-mcve
Status: A Minimal Complete and Verifiable Example has been found for this issue
T-lang
Relevant to the language team, which will review and decide on the PR/issue.
T-types
Relevant to the types team, which will review and decide on the PR/issue.
This code compiles with the comments and does not compile without the comments.
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.
The text was updated successfully, but these errors were encountered: