-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Closure-like blocks capture all generic type and const parameters #65442
Copy link
Copy link
Open
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.AsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.Async-await issues that have been triaged during a working group meeting.T-langRelevant to the language teamRelevant to the language team
Metadata
Metadata
Assignees
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.AsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.Async-await issues that have been triaged during a working group meeting.T-langRelevant to the language teamRelevant to the language team
Type
Fields
Give feedbackNo fields configured for issues without a type.
I'd like to write the following code:
In particular, I would like to have the
impl Traitreturned bybaznot be tied to the lifetime of its&strargument. Sinceimpl Traitcaptures the lifetimes of all generic arguments (as per RFC 1951), I can't write the code this way though. So instead, I triedHowever, with this, I get the error:
This seems odd, since
Qis (intentionally) not used in theasyncblock. I can work around this by adding anasync fnand calling that instead of usingasync move, but that seems like an odd hack:Is it intentional that the
asyncblock "captures"Qhere, even though it never contains aQ?