Misleading help suggests Sync
bound when shareable reference is passed across or into await
#129105
Labels
A-async-await
Area: Async & Await
A-diagnostics
Area: Messages for errors, warnings, and lints
AsyncAwait-Triaged
Async-await issues that have been triaged during a working group meeting.
D-confusing
Diagnostics: Confusing error or lint that should be reworked.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
#59245 results in an error that may be difficult to interpret when structuring generic async code:
The compiler (as of 1.82.0-nightly (80eb5a8 2024-08-13)) produces this error output:
A non-restrictive, but also unintuitive, solution is to make the reference passed to
do_stuff
mutable (i.e. provably exclusive), even though mutability is not required by the function body.Desired outcome
The help heuristic should detect that the
Sync
bound arises due to a shareable reference becoming a member of an async closure for whichSend
is required, and suggest using an exclusive reference as an alternative to restricting the bound.Originally posted by @mzabaluev in #59245 (comment)
The text was updated successfully, but these errors were encountered: