diagnostics for capturing closures that are coerced to fn pointers are not great #71895
Labels
A-closures
Area: Closures (`|…| { … }`)
A-diagnostics
Area: Messages for errors, warnings, and lints
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Given this program (playground):
the error message is currently:
The problem here is that closures can be coerced to
fn
types, but only if they don't capture any variables (and this one does capturey
) -- see #39817 for more details. I think that we ought to give an error like:The text was updated successfully, but these errors were encountered: