-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.D-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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`
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.D-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.