1
1
error[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
3
3
|
4
4
LL | needs_async_fn(async || {
5
5
| -------------- -^^^^^^^
@@ -14,11 +14,32 @@ LL | | });
14
14
| |_____- the requirement to implement `async Fn` derives from here
15
15
|
16
16
note: required by a bound in `needs_async_fn`
17
- --> $DIR/wrong-fn-kind.rs:8 :31
17
+ --> $DIR/wrong-fn-kind.rs:6 :31
18
18
|
19
19
LL | fn needs_async_fn(_: impl async Fn()) {}
20
20
| ^^^^^^^^^^ required by this bound in `needs_async_fn`
21
21
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
23
44
24
45
For more information about this error, try `rustc --explain E0525`.
0 commit comments