async function being !Send due to match retaining type of a consumed value. #114624
Labels
A-async-await
Area: Async & Await
A-auto-traits
Area: auto traits (e.g., `auto trait Send {}`)
C-bug
Category: This is a bug.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Hi,
I tried this code:
playground will the full code : https://play.rust-lang.org/?version=nightly&mode=release&edition=2021&gist=e0c1095262f83a6f62cea40d6059fe3d
I expected to see this happen:
In this case I would expect both
good()
andbad()
async function to be Send and the whole code to compile.This code basically create a !Send value that is consumed by some function that return something Send.
After this point, a
.await
is called. Since the non sendable value have been consumed, I would expect the async function to be SendInstead, this happened:
The function
good()
is Send but not the functionbad()
.It seem that the match somehow retain the non-sendable type even though it should have been consumed.
What is even more surprising is to see the difference of behavior between the let and the match, since I would have expected those to be identical.
I dug a bit through the existing issues and found #93883 and #94067 that kinda look like what I have here, but I cannot for sure know if this it is exactly the same issue.
Meta
rustc --version --verbose
:Note : also reproduced with the available versions in the playground
The text was updated successfully, but these errors were encountered: