-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Async/Await: Confusing error message when using non-Send type in async fn #65667
Comments
Can you clarify @dbrgn whether you are running this on nightly or on beta? We've been doing work on exactly this error message, but it may not be triggering in your particular case. |
Assigning to myself to check if #65345 addresses this. |
@nikomatsakis Sorry for forgetting to mention this. I was on 1.39.0-beta.6. |
I can confirm that with #65345 that the error message is improved in this case:
|
@davidtwco thanks for checking! This is indeed much better. Now the question is whether the |
There was discussion about that in Zulip which might be of interest to you. I wonder if there is something we could do in this diagnostic when the destructor is the reason that the type lives across the await point to help explain this. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@davidtwco I definitely think that destructors are worth trying to "special case" -- we do some similar things in the NLL logic, as I recall. |
With this
Cargo.toml
:...and this
main.rs
:...I get this error message:
If I comment out the unused
rc
assignment, then everything works fine.If comment out the
delay(..).await
statement, it works too!If I put the
rc
assignment in a block, it compiles as well (because therc
is dropped by the timeawait
is called).From what I know about the implementation of async-await, I think this is because a state machine is created that keeps the local variables across multiple await-points, right? In any case, the error message is quite confusing, especially when the await call and the non-
Send
type are not related at all.It seems that we're back at a pre-NLL situation with the borrow checker in async functions.
In summary, two issues:
rc
could be dropped before theawait
call, which would resolve this issueThe text was updated successfully, but these errors were encountered: