Open
Description
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
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: Type systemCategory: An issue proposing an enhancement or a PR with one.Relevant to the compiler team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.