Confusing interaction between associated types, async fn
and impl Future
#89657
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.
S-needs-repro
Status: This issue has no reproduction and needs a reproduction to make progress.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
WG-async
Working group: Async & await
With the following files:
Cargo.toml
:src/main.rs
:It succeeds with
cargo build
(using the secondtransfer
), but if you use the firsttransfer
by runningcargo build --features use_async_fn
, you get a very confusing error:The second
transfer
implementation (used whenuse_async_fn
is off) is a workaround based on the desugar ofasync fn
, plus aCaptures
trait I found on stackoverflow.Confusingly, the error only ever occurs in
_test2
._test3
is especially concerning, because it means that "forgetting" information about the type makes the typechecking succeed somehow!Removing the
Backend::<'a>::MyStorage
associated type, changingstore
tostore<F,MyStorage: Storage<'a>>
, and callingbackend.store::<_,AtomicStorage>(...)
rather thanbackend.store(...)
also fixes the error.This looks like a potential type inference bug, but it might be expected behavior. If it's expected, I think the error messages could use some work.
Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: