Bug when using .flatten()
method that has Item = &'a T
when calling async function inside loop
#126044
Labels
A-async-await
Area: Async & Await
A-auto-traits
Area: auto traits (e.g., `auto trait Send {}`)
A-diagnostics
Area: Messages for errors, warnings, and lints
A-trait-system
Area: Trait system
AsyncAwait-Triaged
Async-await issues that have been triaged during a working group meeting.
C-bug
Category: This is a bug.
D-confusing
Diagnostics: Confusing error or lint that should be reworked.
I tried this code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=f560d75b3eb32ab6d2e0e51590b0337f
I expected to see this happen: code compiles
Instead, this happened:
error: implementation of std::marker::Send is not general enough
Meta
rustc --version --verbose
:Bug exists on
beta
andnightly
versions also.Backtrace
I have working example: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=19183aa875e3dadf501f3b6bdfb61ce4.
It seems like the reason is combination of
.flatten()
method that hasItem = &'a T
when calling async function inside loop. If you try to remove.await
from the line 33, it compiles. If you try to remove.flatten()
as in second link - it compiles.Also, the error seems kinda random. The pattern is as follows:
But every time I change the code, the compiler shows another
T
type in error hint.The text was updated successfully, but these errors were encountered: