11error[E0525]: expected a closure that implements the `async Fn` trait, but this closure only implements `async FnMut`
2- --> $DIR/wrong-fn-kind.rs:11 :20
2+ --> $DIR/wrong-fn-kind.rs:9 :20
33 |
44LL | needs_async_fn(async || {
55 | -------------- -^^^^^^^
@@ -14,11 +14,32 @@ LL | | });
1414 | |_____- the requirement to implement `async Fn` derives from here
1515 |
1616note: required by a bound in `needs_async_fn`
17- --> $DIR/wrong-fn-kind.rs:8 :31
17+ --> $DIR/wrong-fn-kind.rs:6 :31
1818 |
1919LL | fn needs_async_fn(_: impl async Fn()) {}
2020 | ^^^^^^^^^^ required by this bound in `needs_async_fn`
2121
22- error: aborting due to 1 previous error
22+ error[E0525]: expected a closure that implements the `async Fn` trait, but this closure only implements `async FnOnce`
23+ --> $DIR/wrong-fn-kind.rs:15:20
24+ |
25+ LL | needs_async_fn(move || async move {
26+ | -------------- -^^^^^^
27+ | | |
28+ | _____|______________this closure implements `async FnOnce`, not `async Fn`
29+ | | |
30+ | | required by a bound introduced by this call
31+ LL | |
32+ LL | | println!("{x}");
33+ | | - closure is `async FnOnce` because it moves the variable `x` out of its environment
34+ LL | | });
35+ | |_____- the requirement to implement `async Fn` derives from here
36+ |
37+ note: required by a bound in `needs_async_fn`
38+ --> $DIR/wrong-fn-kind.rs:6:31
39+ |
40+ LL | fn needs_async_fn(_: impl async Fn()) {}
41+ | ^^^^^^^^^^ required by this bound in `needs_async_fn`
42+
43+ error: aborting due to 2 previous errors
2344
2445For more information about this error, try `rustc --explain E0525`.
0 commit comments