1
- error[E0277]: expected a `FnMut()` closure, found `{closure@$DIR/move-ref-patterns-closure-captures.rs:9:14: 9:16}`
2
- --> $DIR/move-ref-patterns-closure-captures.rs:17:19
3
- |
1
+ error[E0525]: expected a closure that implements the `FnMut` trait, but this closure only implements `FnOnce`
2
+ --> $DIR/move-ref-patterns-closure-captures.rs:9:14
3
+ |
4
+ LL | let c1 = || {
5
+ | ^^ this closure implements `FnOnce`, not `FnMut`
6
+ ...
7
+ LL | drop::<U>(_x1);
8
+ | --- closure is `FnOnce` because it moves the variable `_x1` out of its environment
9
+ ...
4
10
LL | accept_fn_mut(&c1);
5
- | ------------- ^^^ expected an `FnMut()` closure, found `{closure@$DIR/move-ref-patterns-closure-captures.rs:9:14: 9:16}`
11
+ | ------------- --- the requirement to implement `FnMut` derives from here
6
12
| |
7
13
| required by a bound introduced by this call
8
14
|
9
- = help: the trait `FnMut<()>` is not implemented for closure `{closure@$DIR/move-ref-patterns-closure-captures.rs:9:14: 9:16}`
10
- = note: wrap the `{closure@$DIR/move-ref-patterns-closure-captures.rs:9:14: 9:16}` in a closure with no arguments: `|| { /* code */ }`
11
- = note: `{closure@$DIR/move-ref-patterns-closure-captures.rs:9:14: 9:16}` implements `FnOnce`, but it must implement `FnMut`, which is more general
12
15
note: required by a bound in `accept_fn_mut`
13
16
--> $DIR/move-ref-patterns-closure-captures.rs:4:31
14
17
|
15
18
LL | fn accept_fn_mut(_: &impl FnMut()) {}
16
19
| ^^^^^^^ required by this bound in `accept_fn_mut`
17
20
18
- error[E0277]: expected a `Fn()` closure, found `{closure@$DIR/move-ref-patterns-closure-captures.rs:9:14: 9:16}`
19
- --> $DIR/move-ref-patterns-closure-captures.rs:18:15
20
- |
21
+ error[E0525]: expected a closure that implements the `Fn` trait, but this closure only implements `FnOnce`
22
+ --> $DIR/move-ref-patterns-closure-captures.rs:9:14
23
+ |
24
+ LL | let c1 = || {
25
+ | ^^ this closure implements `FnOnce`, not `Fn`
26
+ ...
27
+ LL | drop::<U>(_x1);
28
+ | --- closure is `FnOnce` because it moves the variable `_x1` out of its environment
29
+ ...
21
30
LL | accept_fn(&c1);
22
- | --------- ^^^ expected an `Fn()` closure, found `{closure@$DIR/move-ref-patterns-closure-captures.rs:9:14: 9:16}`
31
+ | --------- --- the requirement to implement `Fn` derives from here
23
32
| |
24
33
| required by a bound introduced by this call
25
34
|
26
- = help: the trait `Fn<()>` is not implemented for closure `{closure@$DIR/move-ref-patterns-closure-captures.rs:9:14: 9:16}`
27
- = note: wrap the `{closure@$DIR/move-ref-patterns-closure-captures.rs:9:14: 9:16}` in a closure with no arguments: `|| { /* code */ }`
28
- = note: `{closure@$DIR/move-ref-patterns-closure-captures.rs:9:14: 9:16}` implements `FnOnce`, but it must implement `Fn`, which is more general
29
35
note: required by a bound in `accept_fn`
30
36
--> $DIR/move-ref-patterns-closure-captures.rs:5:27
31
37
|
32
38
LL | fn accept_fn(_: &impl Fn()) {}
33
39
| ^^^^ required by this bound in `accept_fn`
34
40
35
- error[E0277]: expected a `Fn()` closure, found `{closure@$DIR/move-ref-patterns-closure-captures.rs:20:14: 20:16}`
36
- --> $DIR/move-ref-patterns-closure-captures.rs:26:15
37
- |
41
+ error[E0525]: expected a closure that implements the `Fn` trait, but this closure only implements `FnMut`
42
+ --> $DIR/move-ref-patterns-closure-captures.rs:20:14
43
+ |
44
+ LL | let c2 = || {
45
+ | ^^ this closure implements `FnMut`, not `Fn`
46
+ ...
47
+ LL | drop::<&mut U>(_x2);
48
+ | --- closure is `FnMut` because it mutates the variable `_x2` here
49
+ ...
38
50
LL | accept_fn(&c2);
39
- | --------- ^^^ expected an `Fn()` closure, found `{closure@$DIR/move-ref-patterns-closure-captures.rs:20:14: 20:16}`
51
+ | --------- --- the requirement to implement `Fn` derives from here
40
52
| |
41
53
| required by a bound introduced by this call
42
54
|
43
- = help: the trait `Fn<()>` is not implemented for closure `{closure@$DIR/move-ref-patterns-closure-captures.rs:20:14: 20:16}`
44
- = note: wrap the `{closure@$DIR/move-ref-patterns-closure-captures.rs:20:14: 20:16}` in a closure with no arguments: `|| { /* code */ }`
45
- = note: `{closure@$DIR/move-ref-patterns-closure-captures.rs:20:14: 20:16}` implements `FnMut`, but it must implement `Fn`, which is more general
46
55
note: required by a bound in `accept_fn`
47
56
--> $DIR/move-ref-patterns-closure-captures.rs:5:27
48
57
|
@@ -51,4 +60,4 @@ LL | fn accept_fn(_: &impl Fn()) {}
51
60
52
61
error: aborting due to 3 previous errors
53
62
54
- For more information about this error, try `rustc --explain E0277 `.
63
+ For more information about this error, try `rustc --explain E0525 `.
0 commit comments