Confusing error message when closures return references based on their arguments #135325
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Code
Current output
Desired output
Rationale and extra context
I'm not sure what this specific limitation would be called, but I ran into it recently and thought that the error could give some advice on how to solve it. I'm not sure what the best way to do that is, so I haven't filled out the desired output section.
I was a bit surprised to learn that
still has the same error (namely,
&Val
and&u32
are assigned two separate lifetimes), whereasfixes the issue. I'm guessing there's some subtle differences in the way a type is created for a closure (even when the return type explicitly written out) versus specifying the type manually, but I'm honestly not sure. If there's some documentation regarding this, it might be a good idea to mention that in the error message.
Other cases
Rust Version
Anything else?
No response
The text was updated successfully, but these errors were encountered: