Unexpected "the parameter type X may not live long enough" error in asynchronous functions #95719
Labels
A-async-await
Area: Async & Await
A-GATs
Area: Generic associated types (GATs)
A-lifetimes
Area: Lifetimes / regions
A-trait-system
Area: Trait system
AsyncAwait-Triaged
Async-await issues that have been triaged during a working group meeting.
F-impl_trait_in_assoc_type
`#![feature(impl_trait_in_assoc_type)]`
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
T-types
Relevant to the types team, which will review and decide on the PR/issue.
WG-async
Working group: Async & await
When a
Future
is wrapped in anasync
block or anasync
function, some of its traits are lost, e.g., Send, thus causing various issues.I tried this code:
I expected to see no compiler errors: the returned
Future
fromasync fn wrap
should beSend
, becauseg.get()
isSend
andasync fn wrap
only wraps the code in an asynchronous code block.Instead, this happened: the returned
Future
fromasync fn wrap
is not anymoreSend
. Note that the error manifests differently if another lifetime bounds are involved in the trait -lifetime bound not satisfied
when assertingis_send(&fut)
. It's even strange to seelifetime bounds
ormay not live long enough
errors when checking theSend
bound.Meta
rustc --version --verbose
:Error
The text was updated successfully, but these errors were encountered: