Files
rust/compiler
Dylan DPC 070de4bc48 Rollup merge of #99942 - compiler-errors:nonsense-un-tupled-fn-trait-error, r=cjgillot
Fix nonsense non-tupled `Fn` trait error

Given this code:

```rust
#![feature(unboxed_closures)]

fn a<F: Fn<usize>>(f: F) {}

fn main() {
    a(|_: usize| {});
}
```

We currently emit this error:
```
error[E0631]: type mismatch in closure arguments
 --> src/main.rs:6:5
  |
6 |     a(|_: usize| {});
  |     ^ ---------- found signature of `fn(usize) -> _`
  |     |
  |     expected signature of `fn(usize) -> _`
  |
note: required by a bound in `a`
 --> src/main.rs:3:9
  |
3 | fn a<F: Fn<usize>>(f: F) {}
  |         ^^^^^^^^^ required by this bound in `a`

For more information about this error, try `rustc --explain E0631`.
error: could not compile `playground` due to previous error
```
Notably, it says the same thing for "expected" and "found"!

Fix the output so that we instead emit:
```
error[E0308]: mismatched types
 --> /home/gh-compiler-errors/test.rs:6:5
  |
6 |     a(|_: usize| {});
  |     ^ types differ
  |
  = note: expected trait `Fn<usize>`
             found trait `Fn<(usize,)>`
note: required by a bound in `a`
 --> /home/gh-compiler-errors/test.rs:3:9
  |
3 | fn a<F: Fn<usize>>(f: F) {}
  |         ^^^^^^^^^ required by this bound in `a`

error: aborting due to previous error
```

The error could still use some work, namely the "mismatched types" part, but I'm leaving it a bit rough since the only way you'd ever get this error is when you're messing with `#![feature(unboxed_closures)]`.

Simply making sure we actually print out the difference in trait-refs is good enough for me. I could probably factor in some additional improvements if those are desired.
2022-08-16 18:16:11 +05:30
..
2022-08-10 17:22:58 +02:00
2022-08-16 11:10:13 +10:00
2022-08-12 16:28:15 -04:00
2022-08-16 11:10:13 +10:00
2022-08-12 16:28:15 -04:00
2022-08-14 19:58:46 +00:00
2022-08-12 16:28:15 -04:00
2022-08-15 15:57:55 +08:00
2022-06-03 17:16:41 -04:00
2022-08-12 16:28:15 -04:00
2022-08-01 08:53:04 +10:00
2022-05-26 13:14:24 +02:00
2022-08-12 16:28:15 -04:00
2022-08-12 16:28:15 -04:00
2022-08-12 16:28:15 -04:00
2022-08-12 16:28:15 -04:00
2022-06-02 10:29:00 +00:00