Open ranile opened 3 years ago
Triage, current output:
error[E0308]: mismatched types
--> src/lib.rs:9:5
|
7 | #[derive(PartialEq)]
| --------- in this derive macro expansion
8 | struct Props {
9 | to: ETest
| ^^^^^^^^^- help: try using a conversion method: `.to_string()`
| |
| expected `String`, found `ETest`
|
= note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info)
This is caused by the desugaring of the derive, and the suggestion not really being applicable in its original context. There are a few different tickets for this category of errors. The general solution would be to stop showing suggestions at all that come from desugarings. We need a good general solution here.
Given the following code:
The current output is:
If we replace our code with compiler's suggestion, we end up with this code:
Which is invalid Rust.
I've only observed this happen with
PartialEq<Type>
andToString
being implemented.Related to: https://github.com/rust-lang/rust/issues/63564
https://github.com/rust-lang/rust/issues/63564 makes this error message even worse as it isn't obvious what's actually wrong here.
I reproduced this with today's nightly build (
2021-03-19 f5f33ec0e0455eefa72f
)Playground link: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=7ac536d0521cefa0cf1f088b9d88db1f