Closed
Description
Given a closure that doesn't fulfill a trait bound, E0525 is emitted but there's no span pointing at where the obligation was introduced:
error[E0525]: expected a closure that implements the `Fn` trait, but this closure only implements `FnMut`
--> src/lib.rs:6:9
|
6 | move || {
| ^^^^^^^ this closure implements `FnMut`, not `Fn`
7 | i += 1;
| - closure is `FnMut` because it mutates the variable `i` here
...
11 | is_fn(f);
| ----- the requirement to implement `Fn` derives from here
We should point at it, like we already do for E0277:
error[E0277]: expected a `Fn<()>` closure, found `[closure@src/lib.rs:7:31: 7:36]`
--> src/lib.rs:9:11
|
9 | is_fn(f);
| ----- ^ expected an `Fn<()>` closure, found `[closure@src/lib.rs:7:31: 7:36]`
| |
| required by a bound introduced by this call
|
= help: the trait `Fn<()>` is not implemented for `[closure@src/lib.rs:7:31: 7:36]`
= note: wrap the `[closure@src/lib.rs:7:31: 7:36]` in a closure with no arguments: `|| { /* code */ }`
= note: `[closure@src/lib.rs:7:31: 7:36]` implements `FnOnce`, but it must implement `Fn`, which is more general
note: required by a bound in `is_fn`
--> src/lib.rs:2:13
|
2 | fn is_fn<F: Fn()>(_: F) {}
| ^^^^ required by this bound in `is_fn`