Closed
Description
rustc 1.12.0-nightly (47b3a98 2016-07-10)
pub struct A;
pub struct B;
pub trait Foo {
type T: PartialEq<A> + PartialEq<B>;
}
pub fn generic<F: Foo>(t: F::T, a: A, b: B) -> bool {
t == a && t == b
}
error: mismatched types [--explain E0308]
--> a.rs:12:10
|>
12 |> t == a && t == b
|> ^ expected struct `B`, found struct `A`
note: expected type `B`
note: found type `A`
error: aborting due to previous error
Changing the order of bounds in the associated type declaration changes which ==
causes a spurious "mismatched types" error.
Using UFCS works around the issue:
PartialEq::<A>::eq(&t, &a) && t == b
The same issue exists with bounds like type T: PartialEq + PartialEq<B>
to compare T
with itself as well as another type.
Metadata
Metadata
Assignees
Labels
Area: Associated items (types, constants & functions)Area: Type systemCategory: This is a bug.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.Medium priorityRelevant to the compiler team, which will review and decide on the PR/issue.