Misleading error message when passing a reference to an FnOnce and a non-reference is expected #47648
Labels
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.
Compiling this code:
gives me the following error:
call
does expect a closure which implementsFnOnce
, not one which implementsFn
as the error message suggests. Accordingly, the line "expected a closure that implements theFn
trait, but this closure only implementsFnOnce
" is very misleading.The actual problem here is that a reference to an
FnOnce
is being passed, rather than theFnOnce
itself. It would be great if the error message reflected this fact.The text was updated successfully, but these errors were encountered: