Open
Description
Sorry for the vague title, please change. I have found a strange bug that is at the intersection of associated types, trait type parameters, and method type parameters.
trait Example {
type Foo;
fn foo<T: AsRef<Self::Foo>>(&self, t: T);
}
impl <A, B> Example for (A, B) where
A: Iterator<Item = u32>,
B: AsRef<A::Item>,
{
type Foo = ();
fn foo<T: AsRef<Self::Foo>>(&self, t: T) {}
}
Compiling playground v0.0.1 (/playground)
error[E0277]: the trait bound `B: std::convert::AsRef<u32>` is not satisfied
--> src/main.rs:14:5
|
14 | fn foo<T: AsRef<Self::Foo>>(&self, t: T) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::AsRef<u32>` is not implemented for `B`
|
= help: consider adding a `where B: std::convert::AsRef<u32>` bound
= note: required because of the requirements on the impl of `Example` for `(A, B)`
error[E0277]: the trait bound `T: std::convert::AsRef<()>` is not satisfied
--> src/main.rs:14:5
|
14 | fn foo<T: AsRef<Self::Foo>>(&self, t: T) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::AsRef<()>` is not implemented for `T`
|
= help: consider adding a `where T: std::convert::AsRef<()>` bound
= note: required by `std::convert::AsRef`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0277`.
error: Could not compile `playground`.
Commenting out line 10 B: AsRef<A::Item>
makes the program compile, or changing it to B: AsRef<u32>
makes it compile (even though A::Item
is a u32
).