Confusing extension of lifetime of reference causes lack of Send in Future #95412
Labels
A-async-await
Area: Async & Await
A-lifetimes
Area: Lifetimes / regions
AsyncAwait-Triaged
Async-await issues that have been triaged during a working group meeting.
C-bug
Category: This is a bug.
I tried this code:
Ideally, it would compile. (Obviously it doesn't make much sense, semantically.)
Instead, it produces this error:
The error message leads me to conclude that the reference
&rx
which is being created by autoref is being "held" across the await point. The following workaround fixes it:(albeit with a clippy FP, rust-lang/rust-clippy#8598)
I tried to produce a repro not involving futures etc., using
&mut
references, but I wasn't able to do so.ISTM that this is sufficiently strange, and the workaround sufficiently unpleasant, that it was worth a report. I'm not sure if I should be tagging this as a diagnostic issue, or what.
Thanks for your attention.
Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: