-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
E0507: AsyncFn vs AsyncFnOnce not given as cause of error, unlike Fn vs FnOnce #150174
Copy link
Copy link
Closed
Closed
Copy link
Labels
A-async-closures`async || {}``async || {}`A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.Category: This is a bug.D-lack-of-suggestionDiagnostics: Adding a (structured) suggestion would increase the quality of the diagnostic.Diagnostics: Adding a (structured) suggestion would increase the quality of the diagnostic.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-async-closures`async || {}``async || {}`A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.Category: This is a bug.D-lack-of-suggestionDiagnostics: Adding a (structured) suggestion would increase the quality of the diagnostic.Diagnostics: Adding a (structured) suggestion would increase the quality of the diagnostic.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Contrived example (that might be possible to distill further, but it's short enough and gets the job done):
This generates the following error on 1.92 stable (playground link):
Nothing you do at the call site will address this (short of making
Foo: Copy). The fundamental underlying issue is the usage ofAsyncFninstead ofAsyncFnOnce, but this isn't even remotely hinted at by the errors.Contrast with the same code but not async, using
Fninstead ofFnOnce(playground link):which generates a much better and actually useful error message:
Naturally, simply changing the
AsyncFntoAsyncFnOnce(which, in this case, is possible), eliminates the error: https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=9a95c91fc4f1df30c06a34f42877ba5a@rustbot label +A-diagnostics +T-compiler +D-lack-of-suggestion +A-async-closures +C-bug