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:9:20
3
- |
4
- LL | needs_async_fn(async || {
5
- | -------------- -^^^^^^^
6
- | | |
7
- | _____|______________this closure implements `async FnMut`, not `async Fn`
8
- | | |
9
- | | required by a bound introduced by this call
10
- LL | |
11
- LL | | x += 1;
12
- | | - closure is `async FnMut` because it mutates the variable `x` here
13
- LL | | });
14
- | |_____- the requirement to implement `async Fn` derives from here
15
- |
16
- note: required by a bound in `needs_async_fn`
17
- --> $DIR/wrong-fn-kind.rs:6:31
18
- |
19
- LL | fn needs_async_fn(_: impl async Fn()) {}
20
- | ^^^^^^^^^^ required by this bound in `needs_async_fn`
21
-
22
1
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
2
+ --> $DIR/wrong-fn-kind.rs:17 :20
24
3
|
25
4
LL | needs_async_fn(move || async move {
26
5
| -------------- -^^^^^^
@@ -35,11 +14,29 @@ LL | | });
35
14
| |_____- the requirement to implement `async Fn` derives from here
36
15
|
37
16
note: required by a bound in `needs_async_fn`
38
- --> $DIR/wrong-fn-kind.rs:6:31
17
+ --> $DIR/wrong-fn-kind.rs:5:27
18
+ |
19
+ LL | fn needs_async_fn(_: impl async Fn()) {}
20
+ | ^^^^^^^^^^ required by this bound in `needs_async_fn`
21
+
22
+ error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure
23
+ --> $DIR/wrong-fn-kind.rs:9:29
39
24
|
40
- LL | fn needs_async_fn(_: impl async Fn()) {}
41
- | ^^^^^^^^^^ required by this bound in `needs_async_fn`
25
+ LL | fn needs_async_fn(_: impl async Fn()) {}
26
+ | --------------- change this to accept `FnMut` instead of `Fn`
27
+ ...
28
+ LL | needs_async_fn(async || {
29
+ | _____--------------_--------_^
30
+ | | | |
31
+ | | | in this closure
32
+ | | expects `Fn` instead of `FnMut`
33
+ LL | |
34
+ LL | | x += 1;
35
+ | | - mutable borrow occurs due to use of `x` in closure
36
+ LL | | });
37
+ | |_____^ cannot borrow as mutable
42
38
43
39
error: aborting due to 2 previous errors
44
40
45
- For more information about this error, try `rustc --explain E0525`.
41
+ Some errors have detailed explanations: E0525, E0596.
42
+ For more information about an error, try `rustc --explain E0525`.
0 commit comments