2018-08-08 14:28:26 +02:00
|
|
|
error[E0525]: expected a closure that implements the `Fn` trait, but this closure only implements `FnOnce`
|
2018-12-25 08:56:47 -07:00
|
|
|
--> $DIR/closure-wrong-kind.rs:10:19
|
2018-08-08 14:28:26 +02:00
|
|
|
|
|
2019-03-09 15:03:44 +03:00
|
|
|
LL | let closure = |_| foo(x);
|
2022-06-27 07:45:35 +02:00
|
|
|
| ^^^ - closure is `FnOnce` because it moves the variable `x` out of its environment
|
|
|
|
| |
|
2018-08-08 14:28:26 +02:00
|
|
|
| this closure implements `FnOnce`, not `Fn`
|
|
|
|
LL | bar(closure);
|
2022-08-18 12:22:07 +00:00
|
|
|
| --- ------- the requirement to implement `Fn` derives from here
|
|
|
|
| |
|
|
|
|
| required by a bound introduced by this call
|
|
|
|
|
|
|
|
|
note: required by a bound in `bar`
|
|
|
|
--> $DIR/closure-wrong-kind.rs:6:11
|
|
|
|
|
|
|
|
|
LL | fn bar<T: Fn(u32)>(_: T) {}
|
|
|
|
| ^^^^^^^ required by this bound in `bar`
|
2018-08-08 14:28:26 +02:00
|
|
|
|
|
|
|
error: aborting due to previous error
|
|
|
|
|
|
|
|
For more information about this error, try `rustc --explain E0525`.
|