rust/compiler/rustc_trait_selection
bors 87e1447aad Auto merge of #117805 - estebank:arg-fn-mismatch, r=petrochenkov
On Fn arg mismatch for a fn path, suggest a closure

When encountering a fn call that has a path to another fn being passed in, where an `Fn` impl is expected, and the arguments differ, suggest wrapping the argument with a closure with the appropriate arguments.

The last `help` is new:

```
error[E0631]: type mismatch in function arguments
  --> $DIR/E0631.rs:9:9
   |
LL |     fn f(_: u64) {}
   |     ------------ found signature defined here
...
LL |     foo(f);
   |     --- ^ expected due to this
   |     |
   |     required by a bound introduced by this call
   |
   = note: expected function signature `fn(usize) -> _`
              found function signature `fn(u64) -> _`
note: required by a bound in `foo`
  --> $DIR/E0631.rs:3:11
   |
LL | fn foo<F: Fn(usize)>(_: F) {}
   |           ^^^^^^^^^ required by this bound in `foo`
help: consider wrapping the function in a closure
   |
LL |     foo(|arg0: usize| f(/* u64 */));
   |         +++++++++++++  +++++++++++
```
2023-11-30 20:12:53 +00:00
..
src Auto merge of #117805 - estebank:arg-fn-mismatch, r=petrochenkov 2023-11-30 20:12:53 +00:00
Cargo.toml Replace custom_encodable with encodable. 2023-11-22 18:37:14 +11:00
messages.ftl Add some additional warnings for duplicated diagnostic items 2023-11-17 07:28:43 +01:00