Compiling the following code
struct TypeA;
struct TypeB;
#[derive(PartialEq)]
struct TypeC(TypeA);
impl std::cmp::PartialEq<TypeA> for TypeB {
fn eq(&self, other: &TypeA) -> bool { true }
}
impl std::cmp::PartialEq<TypeB> for TypeA {
fn eq(&self, other: &TypeB) -> bool { true }
}
fn main() {
let one = TypeC(TypeA);
let two = TypeC(TypeA);
if one == two {
eprintln!("yay");
}
}
produces,
error[E0308]: mismatched types
--> src/main.rs:8:14
|
8 | struct TypeC(TypeA);
| ^^^^^ expected struct `TypeB`, found struct `TypeA`
|
= note: expected type `TypeB`
found type `TypeA`
Which I found very confusing. It would be helpful, at least, if we could indicate that this error occurred during macro expansion?
Playground here: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=ac13781b2c40c1966e18adfb919c236c
Compiling the following code
produces,
Which I found very confusing. It would be helpful, at least, if we could indicate that this error occurred during macro expansion?
Playground here: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=ac13781b2c40c1966e18adfb919c236c