You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following code triggers the manual_async_fn lint:
use std::future::Future;structA;implA{fnf(&self) -> implFuture<Output = ()>{async{}}}fnmain(){let _future = {let a = A;
a.f()};}
However, applying the suggestion of using an async fn causes the code to stop compiling:
error[E0597]: `a` does not live long enough
--> src\main.rs:14:9
|
12 | let _future = {
| ------- borrow later stored here
13 | let a = A;
14 | a.f()
| ^ borrowed value does not live long enough
15 | };
| - `a` dropped here while still borrowed
This is due to async fn implicitly capturing the lifetime of &self in the returned future, while the impl Future syntax does not.
To be consistent with async fn, we should check that the returned future captures all the input lifetimes, or that there are no input lifetimes. See here.
The following code triggers the
manual_async_fn
lint:However, applying the suggestion of using an
async fn
causes the code to stop compiling:This is due to
async fn
implicitly capturing the lifetime of&self
in the returned future, while theimpl Future
syntax does not.Meta
cargo clippy -V
: clippy 0.0.212 (50fc24d 2020-06-25)rustc -Vv
:The text was updated successfully, but these errors were encountered: