diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-08-16 18:16:11 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-16 18:16:11 +0530 |
| commit | 070de4bc4866fe8f36bf1538e01e10eab25f3c79 (patch) | |
| tree | e18648a3d3821cb169d2cc855a56e0b84b0e71cc /compiler/rustc_mir_transform/src/coverage/query.rs | |
| parent | 14a459bf37bc19476d43e0045d078121c12d3fef (diff) | |
| parent | 1c084f15f308f1d977fd763c3d8bed831b44abf2 (diff) | |
| download | rust-070de4bc4866fe8f36bf1538e01e10eab25f3c79.tar.gz rust-070de4bc4866fe8f36bf1538e01e10eab25f3c79.zip | |
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.
Diffstat (limited to 'compiler/rustc_mir_transform/src/coverage/query.rs')
0 files changed, 0 insertions, 0 deletions
