-
-
Notifications
You must be signed in to change notification settings - Fork 15.1k
Future non-Send although non-Send local is dropped before .await #104883
Copy link
Copy link
Closed
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.Async-await issues that have been triaged during a working group meeting.C-bugCategory: This is a bug.Category: This is a bug.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-awaitArea: Async & AwaitArea: Async & AwaitAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.Async-await issues that have been triaged during a working group meeting.C-bugCategory: This is a bug.Category: This is a bug.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.
Rust 1.65 doesn't compile this code:
Playground
It complains that the future is not
Send, reporting the following:I would expect it to compile, since the offending non-Send value is unconditionally dropped before
.await.If I change
drop(non_send)to a block that makes it go out of scope, then it compiles:Playground
As shown, the first example can be trivially transformed to use a scope, but in other situations it might not be as easy. This report is inspired by a post on reddit that described this issue in a slightly more complex scenario.