-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Bug when using .flatten() method that has Item = &'a T when calling async function inside loop #126044
Copy link
Copy link
Open
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-auto-traitsArea: auto traits (e.g., `auto trait Send {}`)Area: auto traits (e.g., `auto trait Send {}`)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-trait-systemArea: Trait systemArea: Trait systemAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.Async-await issues that have been triaged during a working group meeting.C-bugCategory: This is a bug.Category: This is a bug.D-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.fixed-by-higher-ranked-assumptionsFixed by `-Zhigher-ranked-assumptions`Fixed by `-Zhigher-ranked-assumptions`
Metadata
Metadata
Assignees
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-auto-traitsArea: auto traits (e.g., `auto trait Send {}`)Area: auto traits (e.g., `auto trait Send {}`)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-trait-systemArea: Trait systemArea: Trait systemAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.Async-await issues that have been triaged during a working group meeting.C-bugCategory: This is a bug.Category: This is a bug.D-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.fixed-by-higher-ranked-assumptionsFixed by `-Zhigher-ranked-assumptions`Fixed by `-Zhigher-ranked-assumptions`
Type
Fields
Give feedbackNo fields configured for issues without a type.
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 enoughMeta
rustc --version --verbose:Bug exists on
betaandnightlyversions 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 Twhen calling async function inside loop. If you try to remove.awaitfrom 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
Ttype in error hint.