Lifetime error when Send is enforced on async function return type #64176
Labels
A-async-await
Area: Async & Await
AsyncAwait-Triaged
Async-await issues that have been triaged during a working group meeting.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
T-lang
Relevant to the language team, which will review and decide on the PR/issue.
Just like a lot of lifetime issues, I'm not actually sure whether this is a bug in the compiler or a bug in my code.
The following code:
Triggers the following compilation error:
Replacing
T: Send
with justT
makes it compile fine.Replacing
async fn run<F>(mut foo: F)
withasync fn run(mut foo: FooImpl)
(ie. removing the generic parameter) also works fine.Code explanation: calling
foo.next_elem()
return aFuture
that should keepfoo
borrowed, and produces an element (type Elem;
) that still keepsfoo
borrowed.I don't really see the relationship between this behaviour and
Send
. All the types used in this code do implementSend
.My compiler version is
rustc 1.39.0-nightly (c6e9c76c5 2019-09-04)
.The text was updated successfully, but these errors were encountered: